+ 1

Jungle help

I know i need to get a sttring as out put, but how. I dont think the lessons went over this #include <iostream> using namespace std; string Grr; int main() { string animal; while (cin>>animal) if (animal== Grr){ cout<<animal;} return 0; }

5th Aug 2022, 5:04 AM
Angel Jimenez
Angel Jimenez - avatar
5 Answers
0
ex: string animal_sound; cin >> animal_sound; if( animal_sound == "Grr" ) cout << "Lion";
5th Aug 2022, 8:30 AM
Jayakrishna 🇼🇳
0
So theres no point in doing while loop?
5th Aug 2022, 8:31 AM
Angel Jimenez
Angel Jimenez - avatar
0
No. It's just a sample for taking single input. There task has 3 or 4 inputs by space separated. So you need a loop. Work similarly for other 3 animal sounds.
5th Aug 2022, 8:35 AM
Jayakrishna 🇼🇳
0
Got it so just if else should work
5th Aug 2022, 8:37 AM
Angel Jimenez
Angel Jimenez - avatar
0
You can try your easy way.. is that works for multiple inputs? Try it , if it don't work you can come back with your try.. Hope it helps..
5th Aug 2022, 8:41 AM
Jayakrishna 🇼🇳