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

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 I need help with this

4th Sep 2021, 2:16 PM
Mando
Mando - avatar
47 Answers
+ 13
If u really need help Show your attempt First
4th Sep 2021, 2:17 PM
Pariket Thakur
Pariket Thakur - avatar
+ 10
demilade take the C++ course on sololearn and start learning yourself. If you have any doubts, ask in the discussion forum. I see you haven't started any courses. Go to "learn" section and choose a language. Choose C++ if you wanna learn about the code in this discussion thread
5th Sep 2021, 2:09 AM
Rishi
Rishi - avatar
+ 9
U have learn besic
5th Sep 2021, 6:43 AM
Kedar
Kedar - avatar
+ 6
...our code works fine. I see no issue with showing something as simple as (divide by 3)! How else can you help with something as simple? Rather than slamming us for providing the very basic template for a cpp program, maybe suggest OP should start the CPP basic course from scratch?
4th Sep 2021, 2:45 PM
DavX
DavX - avatar
+ 5
#include<iostream> using namespace std; int main() { int crabs,dish; cin >> crabs; dish = crabs / 3; cout<<dish; return 0; } Simple one. The dish needs exactly 3 crabs. So we need to find how many dishes can be made using the given input. This is obtained by dividing the number of crabs by 3. Use the SoloLearn's C++ course for solving these type of questions.
5th Sep 2021, 5:31 AM
Balaraj Kanvi
Balaraj Kanvi - avatar
+ 4
#include <iostream> using namespace std; int main() { int crabs; std::cin >> crabs; std::cout << "You can make " << crabs / 3 << " Seafood Trio's" << endl << endl; if (crabs % 3) { cout << "With " << crabs % 3 << " crab(s) left over!"; } return 0; }
4th Sep 2021, 2:30 PM
DavX
DavX - avatar
+ 4
This is a c++ question
4th Sep 2021, 4:22 PM
DavX
DavX - avatar
+ 4
Oh ok
5th Sep 2021, 3:03 AM
Saivinay Gondrala
Saivinay Gondrala - avatar
+ 4
python x=int(input()) Print(x%3)
5th Sep 2021, 9:22 AM
Nature of me
Nature of me - avatar
+ 3
I don't know C++
5th Sep 2021, 5:47 AM
๛ 𝔾𝕒𝕦𝕥𝕒𝕞 𝕤𝕒𝕣𝕘𝕒𝕣𝕒
๛ 𝔾𝕒𝕦𝕥𝕒𝕞 𝕤𝕒𝕣𝕘𝕒𝕣𝕒 - avatar
+ 3
/* If you divide an Integer number by an integer then it will result an integer with ceil value Code :- */ #include<iostream> using namespace std; int main (){ int crab; cin>>crab; cout<<crab/3; return 0; }
5th Sep 2021, 2:23 PM
Deepak
Deepak - avatar
+ 3
Think whole number division
5th Sep 2021, 10:11 PM
Sonic
Sonic - avatar
+ 3
Florida Miami (Floridan) *Get the number of crabs "n" as input. *Calculate the integer division of n/3(stored as m), ignoring any remainders or decimal numbers. *Output m.
6th Sep 2021, 7:02 AM
Rishi
Rishi - avatar
+ 2
HrCoder didn't see that he uploaded his code
4th Sep 2021, 2:38 PM
Gigi
+ 2
#include <iostream> using namespace std; int main() { int crabs; cin >> crabs; int s = crabs / 3; cout << s << endl; return 0; }
4th Sep 2021, 7:04 PM
Isaac Nyarko
Isaac Nyarko - avatar
+ 2
#include<isotream> namespace std; int main() { Int crabs; Cin>>crabs; Cout<<"x"; Cout<<"y"; }
5th Sep 2021, 6:41 AM
Kedar
Kedar - avatar
+ 2
int num; cin >> num ; int trio = num / 3 ; cout << trio ;
5th Sep 2021, 10:12 PM
Yassine Alsmayli
Yassine Alsmayli - avatar
+ 2
Look at the C++ tutorial on how to do input and output.
5th Sep 2021, 10:12 PM
Sonic
Sonic - avatar
+ 2
I don't know C ++ but I will know C language 💬 -- the print("hello world! "); will almost used in the C program...
6th Sep 2021, 1:09 PM
Shubham Bhatia
Shubham Bhatia - avatar
+ 2
Next time first share your code also so others can analyse your problem. #include <iostream> using namespace std; int main() { int crabs; cin >> crabs; int s = crabs / 3; cout <<s << endl; return 0; }
6th Sep 2021, 1:24 PM
Sachin Yadav
Sachin Yadav - avatar