| Previous | Home | Next |
In this example we are going to print a number triangle. In this number triangle we have 1 in first row,1 2 in second row ,1 2 3 in third row and so on.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the number\t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
getch();
}
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
| Previous | Home | Next |