0

The coutdown challenge

I do it like this #include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here do {cout << n << endl; if ( n%5==0) {cout << "Beep"<<endl;} n--;} while (n>=2); if (n==1) {cout << 1;} return 0; } It work but i think there is some problem, isnt it ? Or a shorter way to do it .-. Thanks

14th Jul 2021, 5:17 AM
Tấn Sang Huỳnh
Tấn Sang Huỳnh - avatar
2 ответов
+ 1
Heres another way that works thats a lil shorter while ( n >= 1) { cout << n << endl; if (n % 5 == 0) { cout << "Beep" << endl; } n--; }
23rd Sep 2021, 11:48 AM
Brent Tyson
Brent Tyson - avatar
0
Oh ... i thought the new line at the end will make it wrong lol. Thx u so much :Đ
14th Jul 2021, 6:05 AM
Tấn Sang Huỳnh
Tấn Sang Huỳnh - avatar