- 1

Can anybody solve this ......

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

10th Dec 2020, 12:46 PM
Aayush Singh Thakur
Aayush Singh Thakur - avatar
5 Réponses
+ 4
Here I found some bugs on your code.I solved the bugs.Now read the comment on this code and you will find what was the problem : https://code.sololearn.com/cA15a7a11A2A
10th Dec 2020, 1:31 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Aayush Singh Thakur , this is a code coach task. If you need help show your attempt, so somebody can help you.
10th Dec 2020, 12:49 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
Aayush Singh Thakur , the start of the loop should be given by the input, not just saying n = 15, it could be other value. Based on your code it can be solved: #include <iostream> using namespace std; int main() { int n; int p; cin >> n; for(p= n;p>0;p--) { cout <<p <<endl; if(p%5 == 0) { cout<<"Beep"<<endl ; } } return 0; }
10th Dec 2020, 1:33 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
#include <iostream> using namespace std; int main() { int n; int p; cin >> n; for(n=15;n>0;n--) { cout <<n <<endl; if(n%5) { cout<<"Beep"<<endl ; } } return 0; } This is what I attempted...
10th Dec 2020, 1:19 PM
Aayush Singh Thakur
Aayush Singh Thakur - avatar