Can someone help me with this in c++ | SoloLearn: Learn to code for FREE!

+15

# Can someone help me with this in c++

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

11/29/2020 6:28:55 AM

Krish Mohan

+14

Oh yeah!!! Thanks a lot to you both

+7

Krish Mohan Wlcm ...But Nasif Rahman is the real legend....

+4

Now can you help?

+4

Thanks But its not showing 20,10,5,15.....

+4

Yeah of course he is He solved my problemππππ

+4

Are you two brothers or good friends

+4

Nasif Rahman apparently "Beep" needs an uppercase "B" according to the spec?

+3

Show ur attempt so that we can help with that....

+3

Krish Mohan n=--n is a totally funny and wrong stmt. --n means n=n-1 So replace n=--n with --n; in ur code and then its correct....

+3

+3

Krish Mohan we r Good Brothers...

+3

Nasif Rahman Krish Mohan Yes otherwise we'll be violating guidelines...

+3

You can use a for loop too. Here's an example : for (int i=n; i > 0; i--) { cout << i << endl; if (i % 5 == 0) { cout << "Beep" << endl; } } It works just the same as Nasif Rahman's while loop.

+3

int n; cin>>n; while (n>0){ n%5==0?cout<<n<<endl<<"bip"<<endl:cout<<n<<endl; --n; }

+3

#include <iostream> using namespace std; int main() { int n; cin >> n; do{ cout<<n; if(n%5==0) { cout<<"Beep"; } n--; } while(n>0); //your code goes here return 0; }

+2

+2

There you go

+2

Okay Is that it??

+2

Ok but for me you are a legend boss

+2

Are you really???