C Program to create ABCD triangle

C Program to create ABCD triangle 


Triangle of ABCD in C Language using Loop Control | Triangle of Alphabets in C language |
#include
main()
{
    char z;
    int j,i,k;
    printf("Enter the number of rows..(Between 1 to 26)\n");
    scanf("%d",&k);
    if(k<1||k>26)
    {
        printf("\n The number entered was not in range of 1 to 26\n"); //For Validation
        printf("exiting...\n");
        exit(0);
    }
    //If Proper Input given by user...
    printf("\n\n");
    for (i=1;i<=k;i++)
    {
        z = 'A';
        for (j=0;j<i;j++)
        {    
            printf ("%c  ",z);
            z++;
        }
    printf("\n\n");
    }
}

No comments:

Post a Comment