0
1.6kviews
Write a program to generate following pattern.

Mumbai University> FE > Sem 2> STRUCTURED PROGRAMMING APPROACH

Marks: 5M

Year: May 2016

2 Answers
0
4views
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,l,n;
printf("Enter number of rows:");
scanf("%d",&n);
for(k=i=1;i<=n;i++)
{    
    for(j=1;j<=n-i;j++) 
    { 
        printf(" ");
    }
    l=k+i-1;
    for(j=1;j<=i;j++)
    {

        printf("%c",(char)(l+64));
        k++;
        l--;
    }
    printf("\n");
}
getch();
}

Output: enter image description here

0
3views
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
printf(“Enter number of rows:”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf(“%d”,j);
}
printf(“\n”);
}
getch();
}

Output:
Enter number of rows: 5
1
12
123
1234
12345
Please log in to add an answer.