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,
1 ответ
+ 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;
}