0

Do While and Break

I tired to hang out the code which is following: int num = 5; while (num > 0) { if (num == 3) break; printf("%d\n", num); num--; } to #include <stdio.h> int main() { int num = 5; do { printf("%d \n", num); num--; } while (num > 0) { if (num == 3) { break; } } return 0; } However, this error pops up. ..\Playground\:9:23: error: expected ';' before '{' token } while (num > 0) { If I want to keep my second codes, what should I change? Please advise,

23rd Nov 2019, 8:34 PM
Hyun Wook Jung
Hyun Wook Jung - avatar
1 Odpowiedź
+ 5
Hyun Wook Jung do like this way #include <stdio.h> int main() { int num = 5; do { if (num == 3) { break; } num--; printf("%d \n", num); }while (num > 0); return 0; }
23rd Nov 2019, 8:43 PM
GAWEN STEASY
GAWEN STEASY - avatar