0

coutdown bug

When i execute the code it comes out correct but at the end of the code there is a empty line after 1. i think this is not letting me complete the challenge. #include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here for(int i=n;1<=n;n--){ cout<<n<<endl; if(0==n%5) cout<<"beep"<<endl; } return 0; }

11th Nov 2021, 4:43 PM
Angel Jimenez
Angel Jimenez - avatar
3 Respuestas
+ 3
Angel Jimenez There is Beep not beep Also i is unused in your for loop. So do this: for(int i = n; i > 0; i--){ cout << i <<endl; if(0 == i % 5) cout << "Beep" << endl; }
11th Nov 2021, 4:55 PM
A͢J
A͢J - avatar
+ 2
Thank you that makes sense of course haha
11th Nov 2021, 5:00 PM
Angel Jimenez
Angel Jimenez - avatar
0
I also tried a do loop and had same results any help is good thank you, int n; cin >> n; //your code goes here do{ cout<<n<<endl; if(0==n%5) cout<<"beep"<<endl; n--; } while(n>0); return 0;
11th Nov 2021, 4:55 PM
Angel Jimenez
Angel Jimenez - avatar