pyramid triangle

Hollow Pyramid Pattern C Programming

Hollow Pyramid Pattern C Programming

In this tutorial, we will discuss Hollow Pyramid Pattern C Programming.

In this topic, we will learn how to create the hollow pyramid pattern and hollow inverted pyramid pattern in C language

Hollow Pyramid pattern 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int rows;
    printf("Enter the  number of rows to Pyramid: ");
    scanf("%d",&rows);
    int i,j,k;
    for(i=1; i<=rows; i++){//Print each row
        for(j=i; j<rows; j++){//Print space for Pyramid shape
             printf(" ");
    }
    for(k=1; k<2*i; k++){//Print "*"

        if(i==rows || (k==1 || k==2*i-1))
            printf("*");
        else
            printf(" ");
    }
        printf("\n");//Move to the next line for print
    }
    getch();
    return 0;
}

 

Hellow Pyramid shape

 

Hollow Pyramid pattern 2

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int rows;
    printf("Enter the  number of rows to Pyramid: ");
    scanf("%d",&rows);
    int i,j,k;
    for(i=rows; i>=1; i--){//Print each row
        for(j=rows; j>i; j--){//Print space for Pyramid shape
             printf(" ");
    }
    for(k=1; k<2*i; k++){//Print "*"

        if(i==rows || (k==1 || k==2*i-1))
            printf("*");
        else
            printf(" ");
    }
        printf("\n");//Move to the next line for print
    }
    return 0;
}
    

 

An inverted Hellow Pyramid shape

 

Suggested for you

For loop in C++ language

For loop in Java language

For loop in C language

For loop in Python language

 

Nested for loop in Java language

Nested for loop in C++ language

Nested for loop in C language

Nested for loop in Python language

 

If statements in C  language

Nested if statements in C  language

 

Floyd’s triangle number pattern using for loop in C

Floyd’s triangle pattern using nested for loop in Java

Floyd’s triangle pattern using nested while loop in Java

 

pyramid number pattern in Java using for loop
C program to Inverted pyramid number pattern
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago