0

Where I'm making mistake ?? Can someone help please 🥺🥺

https://code.sololearn.com/cH0KT5Im7vNE/?ref=app

1st Jan 2022, 1:58 PM
Lalala
Lalala - avatar
4 Respostas
+ 1
// Jungle camping c++ #include <iostream> #include <string> using namespace std; int main(){ string noise ; string Rawr = "Rawr", Chirp = "Chirp", Ssss = "Ssss"; for(int i = 0; i<4; i++) { cin >> noise ; if (noise == Rawr){ cout << "Tiger "; } else if (noise == Chirp){ cout << "Bird " ; } else if (noise == Ssss) { cout << "Snake " ; } else { cout << " " ; } } return 0; } I removed the syntax errors : 1_missed opening brace for the else statement 2_Invalid declaration of the variables Rawr, Chirp and Ssss 3_Invalid use of while loop, so I replaced it by a for loop Input : Ssss Output : Snake Snake Snake Snake
1st Jan 2022, 2:46 PM
VCoder
VCoder - avatar
0
you were trying to use a while as if it were a for, and it was wrong too, anyway ... very good! Keep practicing! keep learning! Is this what you expected? https://code.sololearn.com/clJ2LrLVm9f1/?ref=app
1st Jan 2022, 2:36 PM
CGM
CGM - avatar
0
VCoder when ı look into other examples some use brace and some not in else. How can I know where to use or not
2nd Jan 2022, 9:36 AM
Lalala
Lalala - avatar
0
Lalala , It can be omitted if you only have one line within the code block. Anyway, if you are a beginner, maybe you should always use them Ex .: else return 1; Another example, look at my code again, now it has no braces: https://code.sololearn.com/clJ2LrLVm9f1/?ref=app
2nd Jan 2022, 5:01 PM
CGM
CGM - avatar