+ 1

help me in C++ I'm stuck at lvl 22

You need to make a countdown app. Given a number N as input, output numbers from N to 1 on separate lines. Also, when the current countdown number is a multiple of 5, the app should output "Beep". Sample Input: 12 Sample Output: 12 11 10 Beep 9 8 7 6 5 Beep 4 3 2 1 ______________ so that was the question _____________________ #include <iostream> using namespace std; int main() { int n; cin >>n; for (n;n>=1;n--){ { cout<<n<<endl; } if (n%5==0) { cout<<"beep"<<endl; } } return 0; } I made this program however this isn't working I'm soo confused pls help _________________

20th Mar 2021, 11:40 AM
Syed Sufian
Syed Sufian - avatar
3 ответов
+ 2
Notice the case... In the problem it is Beep with a capital B, but in your code you have beep with a lower case b
21st Mar 2021, 3:29 AM
John Doe
+ 1
Try now Your n variable showing unused inside loop remove it . it will work fine #include <iostream> using namespace std; int main() { int n; cin >>n; for (;n>=1;n--){ { cout<<n<<endl; } if (n%5==0) { cout<<"beep"<<endl; } } return 0; }
20th Mar 2021, 11:49 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
It working fine but have a warning... for(n ; => this is not in effect statement. Make it empty for (;n>=1;n--){ cout<<n<<endl; if (n%5==0) { cout<<"beep"<<endl; } }
20th Mar 2021, 11:51 AM
Jayakrishna 🇮🇳