C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C++

You are a cook in a restaurant. You need exactly 3 crabs to cook your special seafood dish named "Trio". Write a program that will take the number of crabs as input and output how many "Trio" dishes can be made. Sample Input 14 Sample Output 4

6th Sep 2020, 10:21 PM
Tetem
Tetem - avatar
21 Answers
+ 2
Jayakrishna🇮🇳 I got it. int main() { int numbOfCrabs = 3; int x; int sum; //your code goes here cin >> x; sum = x / numbOfCrabs; cout << "" << sum << endl; return 0; }
18th Oct 2020, 2:45 PM
Afrida Sufi
Afrida Sufi - avatar
+ 1
Y'all can try this one!! #include <iostream> using namespace std; int main() { int crabs; cin >> crabs; int Num_trio; Num_trio = crabs / 3; cout <<Num_trio; return 0; }
6th Sep 2021, 9:17 AM
Chalat Rahul
0
What's your try? Pls also post your try..
6th Sep 2020, 10:46 PM
Jayakrishna 🇮🇳
0
To take input, syntax is : cin>>variable_name; & For every 1 dish need 3 crabs so 14/3 = 4; remain 2 wasted int crabs; cin>>crabs; cout<< " dishes made : " << crabs/3 << endl;
6th Sep 2020, 11:12 PM
Jayakrishna 🇮🇳
0
Can you add your original code or link.. Because above one has syntax errors.. It won't give output.. Your code on removing errors, only output same for any input.. Ok. Look int crabs = 14/4; //it stores 3 in crabs cout << “Trio\n”; //it is syntax error because you are using not double quotes, so correct one will appear in green color check "Trio" cout << 4; //it just outputs 4 cin << 14; // wrong syntax for input you used << instead of >> so but for output cout<<14, for input you should use a variable to accept and store value so for input cin>>crabs ; works for ex. cout << “Trio” << crabs << endl; //here also use double quotes....
7th Sep 2020, 7:50 AM
Jayakrishna 🇮🇳
0
Ok Thank you so much!
7th Sep 2020, 7:54 AM
Tetem
Tetem - avatar
0
if any thing not understable in above post, give a reply... You're welcome...
7th Sep 2020, 8:00 AM
Jayakrishna 🇮🇳
0
hi, im new here, I do type like this but it just solve 1 of 5 problem >>> take a look pls.. how can I write for the next one.. #include <iostream> using namespace std; int main() { int numbOfCrabs = 25 / 3; //your code goes here cout << numbOfCrabs; return 0; }
18th Oct 2020, 12:55 PM
Afrida Sufi
Afrida Sufi - avatar
0
Afrida Sufi pls make a new question of your own instead of using other ones.. If this is same problem, some solution is already given above.. Take a look.. I think you need take input into numbOfCrabs and print numbOfCrabs/3. If it is not help, add full problem description.. With your modified try..
18th Oct 2020, 1:07 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 still the same problem but I don‘t know how to solve other 4 case with the same code,, do you got what I mean ? You are a cook in a restaurant. You need exactly 3 crabs to cook your special seafood dish named "Trio". Write a program that will take the number of crabs as input and output how many "Trio" dishes can be made. Sample Input 14 Sample Output 4
18th Oct 2020, 1:33 PM
Afrida Sufi
Afrida Sufi - avatar
0
Updated code? Afrida Sufi
18th Oct 2020, 1:40 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 I did above..
18th Oct 2020, 1:57 PM
Afrida Sufi
Afrida Sufi - avatar
0
Afrida Sufi is it solved,? Try this. int main() { int numbOfCrabs = 3; int x; int sum; //your code goes here cin >> x; sum = x / numbOfCrabs; cout << sum ; return 0; }
18th Oct 2020, 2:54 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 yes it solved already..
18th Oct 2020, 3:10 PM
Afrida Sufi
Afrida Sufi - avatar
0
thank you for sharing your programming code
19th Oct 2020, 5:35 AM
Tetem
Tetem - avatar
19th Oct 2020, 6:40 AM
Afrida Sufi
Afrida Sufi - avatar
0
#include <iostream> using namespace std; int main() { int crabs; cin >> crabs; //your code goes here int Trio = crabs / 3; cout << Trio << endl; return 0; }
28th Jul 2021, 7:26 PM
Octavian Malinici-Pruteanu
Octavian Malinici-Pruteanu - avatar
0
#include <iostream> using namespace std; int main() { int numbOfCrabs = 3; int x; int sum; //your code goes here cin >> x; sum = x / numbOfCrabs; cout << "" << sum << endl; return 0; } Good Luck
25th Jan 2022, 10:57 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
0
Please help me in my coding bus Calculator
18th Jan 2023, 1:29 AM
Robe An Cuyo
Robe An Cuyo - avatar
- 1
int crabs = 14/4; cout << “Trio\n”; cout << 4; cin << 14; cout << “Trio” << crabs << endl; return 0; That was my answer, Thank you!
6th Sep 2020, 10:58 PM
Tetem
Tetem - avatar