Half Pyramid pattern program in c

In the below programs, we are going to see Half pyramid pattern programs in c, which consist of a program of star patterns in c, programs on numbers as well as on alphabets.

1. Half Pyramid star pattern program in c

#include <stdio.h>

int main()
{
    int n;
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        printf("*");
        
        printf("\n");
    }

    return 0;
}
Output:
star-pattern-program-in-c



2. Inverted half pyramid star pattern program in c

#include <stdio.h>

int main()
{
    int n;
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n-i;j++)
        printf("*");
        
        printf("\n");
    }
    return 0;
}
Output:
program-of-star-pattern-in-c



3. Half pyramid number pattern program in c

#include <stdio.h>

int main()
{
    int n;
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        printf("%d",i+1);
        
        printf("\n");
    }
    return 0;
}
Output:

pattern-program-in-c




4. Half pyramid number pattern program in c

#include <stdio.h>

int main()
{
    int n;
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        printf("%d",j+1);
        
        printf("\n");
    }
    return 0;
}
Output:
pattern-program-in-c




5. Half pyramid hallow star pattern program in c

#include <stdio.h>

int main()
{
    int n;
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
         if(j==0 || i==n-1 || i==j)
          printf("*");
         else
          printf(" ");
        }
        printf("\n");
    }

    return 0;
}

Output:
program-of-star-pattern-in-c



6. Inverted half pyramid hallow pattern program in c

#include <stdio.h>

int main()
{
    int n;
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n-i;j++)
        {
         if(i==0 || j==0 || j==n-i-1)
          printf("*");
         else
          printf(" ");
        }
        printf("\n");
    }

    return 0;
}
Output:

program-of-star-pattern-in-c



7. half pyramid alphabet pattern program in c

#include <stdio.h>

int main()
{
    int n;
    char ch;
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        ch='A';
        for(int j=0;j<=i;j++)
        printf("%c",ch++);
        
        printf("\n");
    }
    return 0;
}
Output:
pattern-program-in-c




8. Half pyramid alphabet pattern program in c

#include <stdio.h>

int main()
{
    int n;
    char ch='A';
    printf("Enter the size of n\n");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        printf("%c",ch);
    
        printf("\n");
        ch++;
    }
    return 0;
}
Output:
pattern-program-in-c


Also, see: