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