Write a C Program to Print Double Inverted Pyramid Pattern using For Loop. Here’s simple C Program to Print Double Inverted Pyramid Pattern using For Loop in C Programming Language.
Here is source code of the C Program to Print Double Inverted Pyramid Pattern 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 Double Inverted Pyramid Pattern using For Loop */
#include<stdio.h>
int main() {
int i, j, k;
int blank = 0;
int lines = 6;
char symbol = 'A';
int temp;
int diff[7] = { 0, 1, 3, 5, 7, 9, 11 };
k = 0;
//Step 0
for (i = lines; i >= 0; i--) {
printf("\n");
symbol = 'A';
//step 1
for (j = i; j >= 0; j--) {
printf("%c\t", symbol++);
}
//step 2
blank = diff[k++];
//step 3 - Double space
for (j = 0; j < blank; j++) {
printf("\t");
}
symbol = 'F' - (blank / 2);
if (blank == 0) {
temp = i - 1;
} else {
temp = i;
}
for (j = 0; j <= temp; j++) { //step 4
printf("%c\t", symbol--);
}
}
return (0);
}
Output :
/* C Program to Print Double Inverted Pyramid Pattern using For Loop */
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
Process returned 0
Above is the source code for C Program to Print Double Inverted Pyramid Pattern using For Loop which is successfully compiled and run on Windows System.The Output of the program is shown above .
Here is source code of the C Program to Print Double Inverted Pyramid Pattern 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 : :
Output :
Above is the source code for C Program to Print Double Inverted Pyramid Pattern 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