본문 바로가기

카테고리 없음

C언어 triangle pattern

728x90

/*
* C program to print triangle pyramid pattern using *
*/
#include<stdio.h>
#include<conio.h>
 
int main() {
    int i,j,rows;
    printf("Enter the number of rows\n");
    scanf("%d", &rows);
    
    for(i = 1; i <= rows; i++) {
    /* Prints one row of triangle */
        for(j = 1; j <= i; ++j) {
           printf("* ");
        }
        printf("\n");
    }
    getch();
    return 0;
}

728x90