Countdown | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Countdown

Hi I’m currently doing the countdown on C++ The goal is to get it to countdown and beep on multiples of 5 Mine does this but I still fail yet the third one passes #include <iostream> using namespace std; int main() { int n; cin >> n; do { cout << n << endl; if(n % 5 == 0) { cout << "beep" << endl; } n--; } while (n>0); return 0; }

4th Jan 2022, 12:22 AM
Montell Ifill
4 Answers
+ 2
What about replacing the do while statement to while? If the input is zero, it's beep too.
4th Jan 2022, 12:33 AM
FanYu
FanYu - avatar
+ 1
Thanks but it worked when i changed it to capital B in beep thank you though cause i did run it as a while statement not do while
4th Jan 2022, 12:53 AM
Montell Ifill
0
I think i did it wrong sorry im new I change the do statement to while(n>=1) and it has the same result
4th Jan 2022, 12:40 AM
Montell Ifill
0
do while, execute the block inside do one time no matter with while condition is true or false.
4th Jan 2022, 12:46 AM
FanYu
FanYu - avatar