How can solve this phenomenon | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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".

14th Jan 2022, 8:55 AM
BEATUS BENEDICTO
BEATUS BENEDICTO - avatar
5 Answers
0
Show us your attempt please
14th Jan 2022, 8:57 AM
Slick
Slick - avatar
+ 2
close, go through this step by step https://code.sololearn.com/cB6d60AQiz5c/?ref=app
14th Jan 2022, 9:04 AM
Slick
Slick - avatar
+ 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; } }
14th Jan 2022, 9:03 AM
A͢J
A͢J - avatar
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; }
14th Jan 2022, 8:58 AM
BEATUS BENEDICTO
BEATUS BENEDICTO - avatar
0
Thank you all
14th Jan 2022, 9:13 AM
BEATUS BENEDICTO
BEATUS BENEDICTO - avatar