Advance Triangle Pattern printing 2 || Patterns || C programming
In this, we are going to see a program in which we will be printing Triangular Alphanumeric pattern as shown in above image in C Programming Language.


/*Alphanumeric Pattern 
    1 
   A B 
  2 3 4 
 C D E F 
5 6 7 8 9 
*/
#include <stdio.h>
void main()
{
    int n, m, i, j, count = 1;
    char ch = 'A', space = ' ';
    printf("Enter the value of N: ");
    scanf("%d", &n);

    for (i = 0, m = n - 1; i < n; i++, m--)
    {

        for (j = 0; j < m; j++)
        {
            printf("%c", space);
        }

        for (j = 0; j < i + 1; j++)
        {
            if ((i % 2) == 0)
            {
                printf("%d ", count);
                count++;
            }

            else
            {
                printf("%c ", ch);
                ch++;
            }
        }
        printf("\n");
    }
}


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post