In this tutorial, we will discuss Hollow Pyramid Pattern C Programming.
In this topic, we will learn how to create this pattern and inverted pyramid pattern in this language
#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; }
#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; }
Suggested for you
Do-while loop in Java language
Similar post
Java program to print star pyramid pattern
C program to print star pyramid pattern
C++ program to print star pyramid pattern
Python program to print star pyramid pattern
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
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…