Write in C programming for Half Pyramid of Alphabets

 

Practice in C programming for Half Pyramid of Alphabets
Program-in-c-for-half-pyramid-of-alphabets

Practice in C programming for Half Pyramid of Alphabets


Theory:

To print the half pyramid of the alphabet practice some "for loops" and some of nested  "if-else" conditions not only for better understanding but also clear the concept of loops and if-else conditions. These kinds of problems help you to develop your brain.

Library functions:

  1. #include <stdio.h>
  2. #include <stdlib.h>
Here stdio.h for standard input and output functions.

Datatype:

For pattern, we use some integer type variables for loops.
Character type variable for character inputs.

Input function:

scanf("%c");

Output function:

printf("%c");


Source Code:

//The program in C for Half Pyramid of Alphabets
#include <stdio.h>
#include <stdlib.h>

int main() {
   int i, j;
   char c, alphabet= 'A';
   printf("Enter an uppercase character: ");
   scanf("%c",&c);
   for (i = 1; i <= (c- 'A' + 1); i++){
      for (j = 1; j <= i; j++){
         printf("%c ",alphabet);
      }
      alphabet++;
      printf("\n");
   }
   return 0;
}


Input:

F

Output:

A
B B
C C C
D D D D
E E E E E
F F F F F F

Post a Comment

Don't Post Any Spam Content!!!!

Previous Post Next Post