R4R
Right Place For Right Person TM
 
R4R C C ExamplesPrint Number Star Triangle
previous

Home

Next

Learn C with example

Print Number Star Triangle

In this example we are going to print a number star triangle using C.

In this we are going to print 1 in line one, 2 3 in line two, 4 5 6 into line three,7 8 9 10 and so on...

Source Code of Example

/*
1
2 3
4 5 6
7 8 9 10
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k=1,n;
clrscr();
printf("Enter a number\t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d ",k++);
printf("\n");
}
getch();
}

Output Of Example

Enter an alphabet: a
Change in to uppercase=A
Error processing SSI file

previous

Home

Next

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R