Headlines
Loading...
C Program to print a triangle

C Program to print a triangle

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,r;

clrscr();

printf("\nEnter the number of rows:");

scanf("%d",&r);

printf("\n");

for(i=1;i<=r;i++)

{

for(j=1;j<=i;j++)

{

printf(" %d",j);

}

printf("\n");

}

getch();

}

 

/***************OUTPUT****************

 

Enter the number of rows:6

 

 1

 1 2

 1 2 3

 1 2 3 4

 1 2 3 4 5

 1 2 3 4 5 6                                             */


*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***