0

Cheer Creator

#include <iostream> using namespace std; int main() { int y; int i; cin>>y; if(y>=10){ cout<<"High Five"<<endl; }else if(y<1){ cout<<"shh"<<endl; }else if(y>=1 && y<10){ for(int x=0;x<y;x++){ cout<<"Ra!"<<endl; } } return 0; } why does the fourth test fail?

25th May 2021, 8:53 PM
Francesco Famosi
Francesco Famosi - avatar
3 Respostas
+ 3
Francesco Famosi y should be greater than 10 only so change to y > 10 And remove if condition from final else because it doesn't make sense because when y will be within range 1 to 10 then finally else part will automatically execute. if(y > 10) { cout << "High Five" << endl; } else if(y < 1) { cout << "shh" << endl; } else { for(int x = 0; x < y; x++) { cout << "Ra!" << endl; } } return 0; }
26th May 2021, 2:45 AM
A͢J
A͢J - avatar
+ 2
Lalala i is a short of iteration so mostly people use i but we can use anything
23rd Dec 2021, 5:23 PM
A͢J
A͢J - avatar
+ 1
A͢J why you added x and what the point of using i
23rd Dec 2021, 4:17 PM
Lalala
Lalala - avatar