C++ One test doesn't work, please help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C++ One test doesn't work, please help

the task is: if yard= 0 cout 'shh' if yard <=10 cout 'Ra!' (the same times as yards are) if yard>10 = cout 'High Five' One of the hidden test doen't work. Please help. #include <iostream> using namespace std; int main() { int yard; cin >> yard; if (yard >0&& yard <=10) for (int y= 1; y<=yard; y++){ cout << "Ra!" ; } if (yard >10) cout << "High Five"; if (yard==0) cout << "shh"; return 0; }

28th Dec 2020, 4:15 PM
Саша Топалиди
Саша Топалиди - avatar
2 Answers
+ 10
Code is correct. Just add braces to first if case and inside those braces write that for loop code. Like this: if (yard >0&& yard <=10) { for (int y= 1; y<=yard; y++){ cout << "Ra!" ; } }
28th Dec 2020, 4:34 PM
Ketan [#Be Happy 😄]
Ketan [#Be Happy 😄] - avatar
0
thank you very much!!
28th Dec 2020, 5:28 PM
Саша Топалиди
Саша Топалиди - avatar