0
1.6kviews
Write a program to display the following pattern asking the user for the number of lines

enter image description here

Subject : Structured Programming Approach

Title : Control Structures

Marks : 10M

1 Answer
0
49views
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the number of lines:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
    for(j=1;j<=n-i;j++)
    {
        printf(" ");
    }
    for(j=1;j<=i;j++)
    {
        printf("%d",j);
    }
    for(j=i-1;j>=1;j--)
    {
        printf("%d",j);
    }
    printf("\n");
}
}
Please log in to add an answer.