Header Ads

Diamond Shape Using Alphabet

Write a program to create the following Pyramid using C program?

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

*****************************Program************************

#include<stdio.h>
#include<conio.h>
main()
{
 int r,c,k,m,i;
 printf("Enter the number of lines : ");
 scanf("%d",&m);
 for(r=1;r<=m-1;r++)
    {
        i=0;
        for(c=1;c<=m-r;c++)
        {
            printf(" ");
        }
        for(k=1;k<=r;k++)
        {
            printf("%c ",65+i);
            i++;
        }
        printf("\n");
    }
    for(r=0;r<=m-1;r++)
    {
        i=0;
        for(k=1;k<=r;k++)
        {
            printf(" ");
        }
        for(c=1;c<=m-r;c++)
        {
            printf("%c ",65+i);
            i++;
        }
        printf("\n");
    }
    getch();
 return 0;
}


*****************************Output*************************

screen shot for Diamond shape using alphabet


5 comments:

  1. Please send explanation of this program with it

    ReplyDelete
  2. Simplest explanation , thanks for this program

    ReplyDelete
  3. Sir you can difine in c programe
    in every c programe can easy way difine or solve.sir i want ask questio*(1):-How can logic any programe to find the solution

    ReplyDelete
  4. Thanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family. c program to find lcm of n numbers

    ReplyDelete
  5. Great and that i have a nifty provide: How Many Houses Has Hometown Renovated home interior renovation

    ReplyDelete