Skip to content
Home » Pattern Program Alphabets in C

Pattern Program Alphabets in C

Learn about Pattern Program Alphabets 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.

Pattern Program Alphabets in C

Pattern:

* * * * * 
* A B C * 
* D E F * 
* G H I * 
* * * * * 

Program:

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

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

  for(r=1; r<=n; r++)
  {
    for(c=1; c<=n; c++)
    {
      if(c==1||r==1||c==n||r==n) printf("* ");
      else printf("%c ",ch++);
      if(ch > 'Z') ch='A';
    } 

    printf("\n");
  } 

  return 0;
}

Output:

Enter number of rows: 5
* * * * * 
* A B C * 
* D E F * 
* G H I * 
* * * * * 

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 9 in C
Pattern Program 8 in C