;

C Program to print half pyramid using alphabets(Input is Entered by the User is in Uppercase Character up to which Pattern is Printed)


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to print a half pyramid using alphabets (Input is Entered by the User is in Uppercase Character up to which Pattern is Printed).

Here is the code of the program to print a half pyramid using alphabets.

Code - C Program to print half pyramid using alphabets(Input is Entered by the User is in Uppercase Character up to which Pattern is Printed)
/* C Program to print half pyramid using alphabets
(Input is Entered by the User is in Uppercase Character up to which Pattern is Printed).
In This Program, Input is Entered by the User is in Uppercase Character up to which Pattern is Printed 
A
B B
C C C
D D D D
E E E E E
*/
#include <stdio.h>
int main()
{
    int i, j;
    char input, alphabet = 'A';
    printf("Enter the uppercase character you want to print in the last row: ");
    scanf("%c",&input);
    for(i=1; i <= (input-'A'+1); ++i)
    {
        for(j=1;j<=i;++j)
        {
            printf("%c", alphabet);
        }
        ++alphabet;
        printf("\n");
    }
    return 0;
}
Output

Enter the uppercase character you want to print in the last row: E
A
BB
CCC
DDDD
EEEEE

--------------------------------
Process exited after 4.44 seconds with return value 0
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags