Follow This Blog For more... 😊

Program to print triangle Pattern using numbers (◣) in using alphabets for n number of lines.[Pattern:7]| Using C language| C Program series 28|

👨‍💻Program to print triangle Pattern using numbers ()  in using alphabets for n number of lines.[Pattern:7]

Code :

For n number of LINES:

    /*
    Program to print triangle (Pattern:7) using alphabets for n number of lines.
    For Example:n=5
   
    A
    AB
    ABC
    ABCD
    ABCDE
   
    */
    #include<stdio.h>
    main()
    {
        printf("Program to print triangle (Pattern:7) using alphabets for n number of lines.\n\n");
       
        int i,j,n,k;
        //Here,
        //k for normal integer which used to variable to increment
        //n for number
        //i for row
        //j for colomn
       
        printf("Enter the number:");
        scanf("%d",&n);
       
        for(i=1;i<=n;i++)
        {
            for(j=i,k=65;j>0;j--,k++)
            {
                if(k>90)//where, Ascii value of 90 is 'Z' So, if k>90 then again star from 'A' by setting value of k=65.
                {
                    k=65;
                }
                printf("%c",k);
            }
            printf("\n");
        }
    }

The output of Code:





👉Click for more C Program series Questions.[Questions list]

Comments

Popular Posts