C Programing laungage

adplus-dvertising
C Program example: Print Number Star Triangle
Previous Home Next

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
Previous Home Next