New course! Every coder should learn Generative AI!
Try a free lesson0
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
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;
}
+ 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;
}
0
What's your try?
Pls also post your try..
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;
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....
0
Ok Thank you so much!
0
if any thing not understable in above post, give a reply...
You're welcome...
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;
}
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..
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
0
Updated code? Afrida Sufi
0
Jayakrishna🇮🇳 I did above..
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;
}
0
Jayakrishna🇮🇳 yes it solved already..
0
thank you for sharing your programming code
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;
}
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
0
Please help me in my coding bus Calculator
- 1
int crabs = 14/4;
cout << “Trio\n”;
cout << 4;
cin << 14;
cout << “Trio” << crabs << endl;
return 0;
That was my answer, Thank you!