0
2.2kviews
Write a program to print the following pattern. (Note: Not only 4 lines, it should 8 print n lines taken from user)

enter image description here

Mumbai university > FE > SEM 2 > Structured Programming Approach

Marks: 8M

Year: Dec 2014

1 Answer
0
96views

Algorithm:

  • Start.

  • Declare and initialize variables.

  • Enter the last characters of triangle.

  • If character >A and Character < Z then assign character as character – 32.

  • Print the triangle till last character given by the user.

  • Stop.

Program:

#include<stdio.h>
#include<conio.h>
int main(){
char ch, r, c;
printf("Enter last pyramid character:");
ch=getchar();
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++)  {
for(c='A'; c<=r; c++)
    printf("%c", r);
    printf("\n");
}
return 0;
}

Output:

Enter last pyramid character: D

enter image description here

Please log in to add an answer.