Â
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
1 2 3
A B C D
1 2 3 4 5
*/
#include <stdio.h>
void main()
{
int n, m, i, j;
char 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 ", j + 1);
}
else
{
printf("%c ", ('A' + j));
}
}
printf("\n");
}
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP