Ask a Question

write a code to print A B C D E F E D C B A A B C D E E D C B A A B C C B A A B B A A A

on 2023-01-27 13:06:47   by gourab   on Computer Science & Engineering  1 answers

Prantik

on 2023-02-18 18:57:08  

#include <stdio.h>rnrnint main() {rn char alphabet = 'A';rn int i, j;rnrn // First half of the patternrn for (i = 0; i < 5; i++) {rn for (j = 0; j <= i; j++) {rn printf("%c ", alphabet + j);rn }rn for (j = i-1; j >= 0; j--) {rn printf("%c ", alphabet + j);rn }rn printf("n");rn }rn rn // Second half of the patternrn for (i = 4; i >= 0; i--) {rn for (j = 0; j <= i; j++) {rn printf("%c ", alphabet + j);rn }rn for (j = i-1; j >= 0; j--) {rn printf("%c ", alphabet + j);rn }rn printf("n");rn }rn rn // Final rowrn printf("%c", alphabet);rn return 0;rn}