Search This Blog

Loading...

C Program to print pyramid of small letter and capital letter abcd in C Programming

Code for Program to print pyramid of small letter and capital letter abcd in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
        int i,n,j;
        char c,ch;
        clrscr();
        printf("\n Please Give The Value of N:  ");
        scanf("%d",&n);
        if(n>20)
        {
            printf("\n N MUST BE LESS THAN OR EQUAL TO 20 ");
            printf("\n OTHERWISE IT IS NOT DISPLAY AS PYRAMID");
            printf(" OR NOT FIT IN ");
        }
        else
        {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n-i;j++)
            printf("  ");
            for(j=1,c=97,ch=64;j<=i;j++,c++,ch++)
            {
                if(j%2==1)
                {
                    printf(" %c  ",c);
                    c=c-1;
                }
                else
                {
                    printf(" %c  ",ch);
                    ch=ch-1;
                }
            }
            printf("\n");

        }
    }
    getch();
}
********************** OUTPUT *************************************
     Please Give The Value of N:  7

                 a
               a   A
             a   A   b
           a   A   b   B
         a   A   b   B   c
       a   A   b   B   c   C
     a   A   b   B   c   C   d
*********************************************************************[/Code]

No comments:

Post a Comment