#include <stdio.h>
int main() {
/* while문 : 조건이 참인 동안 반복
while (조건) {
반복할 코드;
} */
// do-while문 : 무조건 한 번은 실행하고 조건이 참인 동안 반복
// do {
// 반복할 코드;
// } while (조건);
int i = 3;
do {
printf("%d\n", i--);
} while (i > 0);
int a = 1;
do {
printf("a는 %d\n", a);
a++;
} while (a <= 5);
int b = 0;
do {
printf("이 문장은 최소 1번 실행됩니다.\n");
} while (b > 0);
printf("----문제----\n");
// 1부터 100까지 합 구하기
int j = 1, sum = 0;
do {
sum += j;
j++;
} while (j <= 100);
printf("%d\n", sum);
printf("----숙제----\n");
int c = 1;
do {
printf("%d ", c);
c += 2;
}while (c <= 10);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: