+ 1

# Countdown (End of module project)

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 https://code.sololearn.com/cXEEucnUQGaD/?ref=app

2nd Mar 2021, 3:43 AM
Tahiti🌍Castillo
6 Réponses
0
I solved this using while loop. Write if statement inside loop. if n % 5 == 0 print Beep else n
2nd Mar 2021, 5:14 AM
Hyperjones
+ 3
if (n%5=0) this is not a proper statement, must be if( n%5==0 ) = is a equality operator , == is a comparision operator cout <<n, n-- << endl; this is also incomplete statement . Remove Comma cout<< n << n-- <<endl; and here you just need cout<< n-- <<endl; and bring if clouse into while loop to work as required... Hope it helps...
2nd Mar 2021, 8:49 AM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 , that is extremely helpful. Thank you 🙏🏽. I’m adding it to my notes.
2nd Mar 2021, 6:10 PM
Tahiti🌍Castillo
+ 1
Tahiti🍷 You're welcome..
2nd Mar 2021, 6:14 PM
Jayakrishna 🇮🇳
+ 1
// I did it with a for loop #include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here for(;n>=1;){ if(n%5==0 && n!=0) { cout << n << endl; cout << "Beep" << endl; n--; } else { cout<<n<<endl; n--; } } return 0; }
5th Feb 2022, 12:11 AM
William Alley
0
I’m having trouble understanding what’s causing the bug. 🐜😫🦟
2nd Mar 2021, 3:45 AM
Tahiti🌍Castillo