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

Jungle camping question

Can anyone help me to find the mistake of this code related to the jungle camping question in code coach? #include <iostream> #include <string.h> using namespace std; int main() { int i,name,j; cin>>name; string a,b,c,d,sounds[name]; a="Grr"; b="Rawr"; c="Ssss"; d="Chirp"; for(j=0;j<name;j++){ cin>>sounds[j]; cout<<sounds[j]; } for(i=0;i<4;i++) { if (sounds[i]==a) cout<<"Lion"<<" "; if (sounds[i]==b) cout<<"Tiger"<<" "; if (sounds[i]==c) cout<<"Snake"<<" "; if (sounds[i]==d) cout<<"Bird"<<" "; } return 0; }

2nd Feb 2021, 6:53 AM
Kalindu Wanasinghe
Kalindu Wanasinghe - avatar
2 Answers
+ 3
The input Instructions clearly specify that that input will be sounds of animals, along with an example. They will not provide you with the number of sounds which are there in input.
2nd Feb 2021, 7:49 AM
Arsenic
Arsenic - avatar
+ 1
The task is : the input should be a string not an int and after each animal in output u should add a space I tried to understand ur code but i don't use c++
2nd Feb 2021, 7:41 AM
Nassera
Nassera - avatar