Q. Write a C program to display the following pattern:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Ans.
/*program to design the above pattern*/
#include<stdio.h>
#include<conio.h>
void main()
int r,c,n=1;
clrscr();
for(r=1; r<=5; r++)
{
for(c=1; c<=r; r++)
{
printf("%3d",n++);
}
printf("\n");
}
getch();
}
Output:-
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Comments
Post a Comment