Write a C program to generate the following pattern for n lines:

Solution:
For printing the above pattern, first print top 4 lines and then print last 3 lines.
Output:


Solution:
For printing the above pattern, first print top 4 lines and then print last 3 lines.
#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=4;i++) // This loop prints top 4 lines.
{
for(j=1;j<=i;j++)
{
printf("%d\t",j);
}
printf("\n");
}
for(i=3;i>=1;i--) // This loop prints last 3 lines
{
for(j=1;j<=i;j++)
{
printf("%d\t",j); // \t gives the tab between numbers.
}
printf("\n");
}
return 0;
}
Output:



