+ 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; }
4 Respuestas
+ 2
What about replacing the do while statement to while? If the input is zero, it's beep too.
+ 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
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
0
do while, execute the block inside do one time no matter with while condition is true or false.