Alphabet Pattern - 4

In c language you can print any Alphabet Pattern. Here i will show you how to print Alphabet Pattern in c language with explanation.

Print Alphabet Pattern Program in C




#include <stdio.h>

int main()
{
    int i, j;
    for(i=5;i>=1;i--)
    {
        for(j=5;j>=i;j--)
        {
            printf("%c",'A' + j-1);
        }
        printf("\n");
    }

    return 0;
}




Output:


E
ED
EDC
EDCB
EDCBA




#include <stdio.h>

int main()
{
    int i, j,n;
    printf("Enter size of triangle:");
    scanf("%d",&n);
    if(n<=26)
    {
    for(i=n;i>=1;i--)
    {
        for(j=n;j>=i;j--)
        {
            printf("%c",'A' + j-1);
        }
        printf("\n");
    }

    }
    else
    {
      printf("Total alpha bits 26 only and you enter number is not correct..");
    }

    return 0;
}




Output:


Enter size of triangle:23
W
WV
WVU
WVUT
WVUTS
WVUTSR
WVUTSRQ
WVUTSRQP
WVUTSRQPO
WVUTSRQPON
WVUTSRQPONM
WVUTSRQPONML
WVUTSRQPONMLK
WVUTSRQPONMLKJ
WVUTSRQPONMLKJI
WVUTSRQPONMLKJIH
WVUTSRQPONMLKJIHG
WVUTSRQPONMLKJIHGF
WVUTSRQPONMLKJIHGFE
WVUTSRQPONMLKJIHGFED
WVUTSRQPONMLKJIHGFEDC
WVUTSRQPONMLKJIHGFEDCB
WVUTSRQPONMLKJIHGFEDCBA

Process returned 0 (0x0)   execution time : 3.248 s

Enter size of triangle:27

Total alpha bits 26 only and you enter number is not correct..




Instagram