C Pattern Programs to Print Pyramids


Get various c pattern programs which mostly asked for exams and we provide you with the easy logic’s.


C Program to Print Half Pyramid of Numbers:

C Program to Print Half Pyramid of Numbers

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("%d",j);
        }
        printf("\n");
    }
}

OUTPUT:

1
12
123
1234
12345


C Program to Print Half Pyramid of Alphabets:

C Program to Print Half Pyramid of Alphabets

#include<stdio.h>
main()
{
    int i,j;
    char a='A';
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("%c",a);
        }
        printf("\n");
        a++;
    }
}

OUTPUT:

A
BB
CCC
DDDD
EEEEE


C Program to Print Half Pyramid of Stars:

C Program to Print Half Pyramid of Stars

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("*");
        }
        printf("\n");
    }
}

OUTPUT:

*
**
***
****
*****


C Program to Print Inverted Half Pyramid of Stars:

C Program to Print Inverted Half Pyramid of Stars

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j<=6-i)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

*****
****
***
**
*


C Program to Print Inverted Half Pyramid of Numbers:

C Program to Print Inverted Half Pyramid of Numbers

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j<=6-i)
                printf("%d",j);
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

12345
1234
123
12
1


C Program to Print Inverted Half Pyramid of Alphabets:

C Program to Print Inverted Half Pyramid of Alphabets

#include<stdio.h>
main()
{
    int i,j;
    char a='A';
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j<=6-i)
            {
                printf("%c",a);
                a++;
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

ABCDE
FGHI
JKL
MN
O


C Program to Print Reflected Inverted Half Pyramid of Stars:

C Program to Print Reflected Inverted Half Pyramid of Stars

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j>=i)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

*****
 ****
  ***
   **
    *






C Program to Print Reflected Inverted Half Pyramid of Numbers:

C Program to Print Reflected Inverted Half Pyramid of Numbers

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j>=i)
                printf("%d",j);
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

12345
 2345
  345
   45
    5


C Program to Print Reflected Inverted Half Pyramid of Alphabets:

C Program to Print Reflected Inverted Half Pyramid of Alphabets

#include<stdio.h>
main()
{
    int i,j;
    char a='A';
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j>=i)
            {
                printf("%c",a);
                a++;
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

ABCDE
 FGHI
  JKL
   MN
    O


C Program to Print Reflected Half Pyramid of Numbers:

C Program to Print Reflected Half Pyramid of Numbers

#include<stdio.h>
main()
{
    int i,j,p=1;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j>=6-i)
            {
                printf("%d",p);
                p++;
            }
            else
                printf(" ");
        }
        p=1;
        printf("\n");
    }
}

OUTPUT:

    1
   12
  123
 1234
12345


C Program to Print Reflected Half Pyramid of Alphabets:

C Program to Print Reflected Half Pyramid of Alphabets

#include<stdio.h>
main()
{
    int i,j;
    char p='A';
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j>=6-i)
            {
                printf("%c",p);
                p++;
            }
            else
                printf(" ");
        }
        p='A';
        printf("\n");
    }
}

OUTPUT:

    A
   AB
  ABC
 ABCD
ABCDE


C Program to Print Reflected Half Pyramid of Stars:

C Program to Print Reflected Half Pyramid of Stars

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j>=6-i)
            {
                printf("*");
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

    *
   **
  ***
 ****
*****


C Program to Print Half Pyramid of # and ?:

C Program to Print Half Pyramid of # and

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j<=i)
            {
             if(j%2==0)
                printf("#");
             else
                printf("?");
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

?
?#
?#?
?#?#
?#?#?


C Program to Print Reflected Inverted Half Pyramid of number and Star:

C Program to Print Reflected Inverted Half Pyramid of Symbol and Star

#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=5;j++)
        {
            if(j>=i)
            {
                if(i%2==0)
                  printf("%d",i);
                else
                    printf("*");
            }
            else
                printf(" ");
        }
        printf("\n");
    }
}

OUTPUT:

*****
 2222
  ***
   44
    *


C Program to Print Half Upper Diamond of Star:

C Program to Print Half Upper Diamond of Star

#include<stdio.h>
main()
{
 int i,j;
 for(i=1;i<=5;i++)
 {
   for(j=1;j<=9;j++)
   {
    if(j>=6-i && j<=4+i)
      printf("*");
    else
      printf(" ");
   }
   printf("\n");
 }
}

OUTPUT:

    *
   ***
  *****
 *******
*********


C Program to Print Half Upper Diamond of Number:

C Program to Print Half Upper Diamond of Number

#include<stdio.h>
main()
{
 int i,j;
 for(i=1;i<=5;i++)
 {
   for(j=1;j<=9;j++)
   {
    if(j>=6-i && j<=4+i)
      printf("%d",i);
    else
      printf(" ");
   }
   printf("\n");
 }
}

OUTPUT:

    1
   222
  33333
 4444444
555555555


C Program to Print Half Upper Diamond of Alphabet:

C Program to Print Half Upper Diamond of Alphabet1

#include<stdio.h>
main()
{
 int i,j;
 char a='A';
 for(i=1;i<=5;i++)
 {
   for(j=1;j<=9;j++)
   {
    if(j>=6-i && j<=4+i)
    {
      printf("%c",a);
      a++;
    }
    else
      printf(" ");
   }
   printf("\n");
 }
}

OUTPUT:

    A
   BCD
  EFGHI
 JKLMNOP
QRSTUVWXY


C Program to Print Diamond Pattern:

C Program to Print Diamond Pattern

#include <stdio.h>
 main()
{
    int num,i,k,cnt=1;

    printf("Enter number of Rows\n");
    scanf("%d",&num);
    cnt=num-1;
    for(k=1;k<=num;k++)
    {
        for(i=1;i<=cnt;i++)
            printf(" ");
        cnt--;
        for(i=1;i<=2*k-1;i++)
            printf("*");
        printf("\n");
     }
     cnt=1;
     for(k=1;k<=num-1;k++)
     {
         for(i=1;i<=cnt;i++)
             printf(" ");
         cnt++;
         for(i=1;i<=2*(num-k)-1;i++)
             printf("*");
         printf("\n");
      }
}

OUTPUT:

Enter number of rows
6
     *
    ***
   *****
  *******
 *********
***********
 *********
  *******
   *****
    ***
     *

 

This are some c pattern programs which are mainly important suggested mostly university. Still, you don’t find any pattern program here you can comment below for which patter program you want and we will provide you that program as soon as possible.

If you have any problem don’t forget to comment.



3 thoughts on “

    1. Thanks For Commenting Prerna, here’s your code for given pattern:

      #include
      main()
      {
      int i,j;
      for(i=1;i<=5;i++) { char ch='A'; for(j=1;j<=10;j++) { if(j<=6-i){ printf("%d%c",j,ch); ch++; } else printf(" "); } printf("\n"); } } Let me know if it works.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.