Skip to content
Home » Alphabet Square Pattern Program in C

Alphabet Square Pattern Program in C

Learn about Alphabet Square 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 Square Pattern Program in C

Pattern:

  a  a  a  a  a
  B  B  B  B  B
  c  c  c  c  c
  D  D  D  D  D
  e  e  e  e  e

Program:

#include<stdio.h>
int main()
{
   int n;

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

   for(int r=1; r<=n; r++)
   {
     for(int c=1; c<=n; c++)
     {
       if(r%2==0) printf("%3c", r+64);
       else printf("%3c", r+96);
     }
     printf("\n");
   }

   return 0;
}

Output:

Enter the number of rows: 5
  a  a  a  a  a
  B  B  B  B  B
  c  c  c  c  c
  D  D  D  D  D
  e  e  e  e  e

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