Skip to content
Home » Alphabet and Number Pattern Program in C

Alphabet and Number Pattern Program in C

Learn about Alphabet and Number Pattern Program in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Alphabet and Number Pattern Program in C

Pattern:

    A
    1    1
    B    B    B
    2    2    2    2
    C    C    C    C    C

Program:

#include<stdio.h>
int main()
{
  int n, r, c, a=0;
  char ch='A';

  printf("Enter number of rows: ");
  scanf("%d",&n);

  for(r=1; r<=n; r++)
  {
    for(c=1; c<=r; c++)
    {
      if(r%2==1) printf("%5c",ch);
      else printf("%5d",a);
    }

    printf("\n");
    if(r%2==0) ch++;
    else a++;
  }

  return 0;
}

Output:

Enter number of rows: 5
    A
    1    1
    B    B    B
    2    2    2    2
    C    C    C    C    C

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Pattern Program 12 in C
Pattern Program 11 in C