+ 1

C++ simple assignment

problem: 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". new learner here I manage to countdown the n to 1 but I struggling in how i will put the beep. Please help. This is what I done int n; cin >> n; do { cout << n << "\n"; n--; }while (n >= 1);

2nd Oct 2022, 3:02 AM
Zeref Dragneel
Zeref Dragneel - avatar
2 odpowiedzi
+ 4
You need to add condition inside loop like this If number is divisible by 5 then print beep if num%5==0 // remainder zero it's multiple of 5 Print beep
2nd Oct 2022, 3:22 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
thank you it worked
2nd Oct 2022, 3:51 AM
Zeref Dragneel
Zeref Dragneel - avatar