#include <stdio.h>

int main() {
    /* 반복문 for while do-while

    for (초기식; 조건식; 증감식) {
        반복할 코드;
    }

    while (조건식) {
        반복할 코드(증감식 포함) ;
    }

    do {
        반복할 코드;
    } while (조건식);
    */

    // 이중 반복문 : 반복문 안에 반복문이 있는 구조
    for (int i = 1; i <= 3; i++) {
        printf("첫 번째 반복문 : %d\n", i);
        for (int j = 1; j <= 5; j++) {
            printf("\t두 번째 반복문 : %d\n", j);
        }
    }

    // 구구단 만들기
    for (int i = 2; i <= 9; i++) {
        printf("%d단 출력\n", i);
        for (int j = 1; j <= 9; j++) {
            printf("%d x %d = %d\n", i, j, i * j);
        }
    }

    // 별 피라미드 만들기
    for (int i = 1; i <= 5; i++) {
        for (int j = 1; j <= i; j++) {
            printf("*");
        }
        printf("\n");
    }

    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: