Q:

C Program to Print Letters Pyramid using For Loop

0

Write a C Program to Print Letters Pyramid using For Loop. Here’s simple C Program to Print Letters Pyramid using For Loop in C Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Here is source code of the C Program to Print Letters Pyramid using For Loop. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.

 
 

SOURCE CODE : :

/*  C Program to Print Letters Pyramid using For Loop  */

#include<stdio.h>

int main() {
   int i, j;
   char symbol = 'A';
   int num;
   int count = 1;

   printf("Enter the number of Letters in Pyramid ");
   printf("(less than 26) : ");
   scanf("%d", &num);

   for (i = 1; i <= num; i++) {
      for (j = 0; j <= (count / 2); j++) {
         printf("%c ", symbol++);
      }

      symbol = symbol - 2;

      for (j = 0; j < (count / 2); j++) {
         printf("%c ", symbol--);
      }

      count = count + 2;
      symbol = 'A';
      printf("\n");
   }
   return (0);
}

Output : :


/*  C Program to Print Letters Pyramid using For Loop  */

Enter the number of Letters in Pyramid (less than 26): 13

A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
A B C D E F E D C B A
A B C D E F G F E D C B A
A B C D E F G H G F E D C B A
A B C D E F G H I H G F E D C B A
A B C D E F G H I J I H G F E D C B A
A B C D E F G H I J K J I H G F E D C B A
A B C D E F G H I J K L K J I H G F E D C B A
A B C D E F G H I J K L M L K J I H G F E D C B A

Above is the source code for C Program to Print Letters Pyramid using For Loop which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a C Program to Print Number Pyramid using Fo... >>
<< C Program to Print Pyramid of Multiplication Table...