0

Please help me on C++

I tried to compile the below code in "Code blocks" and in "Sololearn code playground". The result is not the same. Its just a count down counter but the result at the beginning is not the same. #include <iostream> using namespace std; int main() { int n=0; cin >> n; while(n>0) { if(n%5==0) {cout << "break" << endl;} cout << n << endl; n--; } return 0; }

18th Sep 2021, 2:54 PM
Justin VI
3 Respostas
+ 1
What output did you expected and what did you got on both ? Also what compiler are you using with code::blocks ?
18th Sep 2021, 3:07 PM
Arsenic
Arsenic - avatar
0
My output is looks like the below if I give the in put 24. 24 24 23 22 21 break 20 19 18 17 16 break 15 14 13 12 11 break 10 9 8 7 6 break 5 4 3 2 1 Please note that, at the beginning 24 printed two times in code blocks where in Solo learn not printed two times. I used GNU CC compiler in Codeblocks.
18th Sep 2021, 3:19 PM
Justin VI
0
Justin VI that initial "24" is what you typed to give program an input. Which unlike your system, sololearn takes seperately.
18th Sep 2021, 3:24 PM
Arsenic
Arsenic - avatar