+ 1
How can solve this phenomenon
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".
5 Answers
0
Show us your attempt please
+ 2
close, go through this step by step
https://code.sololearn.com/cB6d60AQiz5c/?ref=app
+ 1
BEATUS BENEDICTO
Why did you print a - 1?
also there is a-- so a = a - 1 doesn't make sense
Also you need single loop not two loops
for(int a = b; a >= 1 ;a--) {
cout << a << endl;
if (a % 5 == 0) {
cout << "Beep" << endl;
}
}
0
Hi!
Here is what I made to solve this:
#include <iostream>
using namespace std;
int main() {
int b;
cin>>b;
for(int a=b;a>=1;a--) {
cout<<a<<endl;
while (a%5==0) {
cout<<"Beep"<<endl<<a-1<<endl;
a=a-1;
}
}
return 0;
}
0
Thank you all