0

Coutdown

I couldnt code the coutdown question... It always giving me wrong out put..... I need the "Beep" before the number My code while(n>0){ cout<<n<<"\n"; n--; if(n%5==0){ cout<<"Beep \n"; } }

1st May 2021, 3:39 PM
Insecure Rush
Insecure Rush - avatar
3 Respuestas
+ 1
Perform the check before decrementing the value of *n* Here is a fix 👇 https://code.sololearn.com/cK48SSnRgQGX/?ref=app
1st May 2021, 3:46 PM
Arsenic
Arsenic - avatar
0
Thanks alot, I took a weak to reach this code.. But coudnt figure how to solve that.... U r awesome... |:^)
1st May 2021, 3:49 PM
Insecure Rush
Insecure Rush - avatar
0
Or use for loop anyways both are same I was talking about for(i=n;i>0;i--){ cout << n<<endl; If(n%5==0) cout << "Beep\n"; } Well there are too many methods
1st May 2021, 3:52 PM
Shunon
Shunon - avatar