1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
Program code
#include <stdio.h>
#include <conio.h>
void main()
{
int inner, outer, rows=1;
clrscr();
printf(“How many rows do you want to see? \n”);
scanf(“%d”, &rows);
printf(“The pattern is displayed below.\n”);
for (outer=1;outer<=rows;outer++)
{
for (inner=1;inner<=outer;inner++)
printf(“%d\t”,inner);
printf(“\n\n”);
}
getch();
}
Example of output
How many rows do you want to see?
7
The pattern is displayed below.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
No comments:
Post a Comment