Q16 Write a c program to produce the following output: 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

Write a program to produce the following output:

Program: 108

Write a c program to produce the following output:

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

#include<stdio.h>
#include<conio.h>
int main()
{
    int i, j, k,sp;

    //print 7th row
    for(i=0;i<=6;i++)
    {
        for(j=65;j<=71-i;j++) //loop for first half
        {
            printf("%c",j);

        }

        //add space between these string
        for(sp=1;sp<=i*2-1;sp++)
            printf(" ");

        for(k=71-i;k>=65;k--) //loop for next half (Second half)
        {
            if(k==71);
            else
                printf("%c", k);
        }


    printf("\n");
    }
}

Output:

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

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.