In this tutorial, we will discuss a simple concept of the Program to Double pyramid star pattern in C++
In this post, we will learn how to create double (integrated) pyramid star pattern in C++ language.
We can use for loop, while loop or do while loop to display different integrated star patterns.
Here, we will use for loop to print different integrated pyramid star patterns
Program 1
#include <iostream> #include <conio.h> using namespace std; int main() { int rows,i,j; cout << "Enter the number of rows: "<< endl; cin>>rows;//take input from user for rows for(i=1; i<=rows; i++){ //print upper part for(j=i; j<=rows; j++){ cout <<"*";//print star to upper part } cout << "\n"; } for(i=rows-1; i>=1; i--){ //print lower part for(j=i; j<=rows; j++){ cout << "*";//print star to lower part } cout << "\n"; } getch(); return 0; }
When the above code is executed, it produces the following result
Enter the number of rows: 6 ****** ***** **** *** ** * ** *** **** ***** ******
Program 2
#include <iostream> #include <conio.h> using namespace std; int main() { int rows,i,j,k; cout<<"Enter the number of rows\n"; cin>>rows;//take input from user for rows for(i=1; i<=rows; i++){ //print upper part for(j=1; j<=i; j++){ cout<<" "; } for(k=i; k<=rows; k++){ cout<<"*";//print star to upper part cout<<" "; } cout<<"\n";//move to next line } for(i=rows-1; i>=1; i--){ //print lower part for(j=1; j<=i; j++){ cout<<" "; } for(k=i; k<=rows; k++){ cout<<"*";//print star to lower part cout<<" "; } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following result
Enter the number of rows: 6 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Program 3
#include <iostream> #include <conio.h> using namespace std; int main() { int rows,i,j; cout<<"Enter the number of rows: "; cin>>rows;//take input from user to rows for(i=1; i<=rows; i++){ //print upper part for(j=1; j<i; j++){ cout<<" ";//print space } for(j=i; j<=rows; j++){ cout<<"*"; } cout<<"\n"; } for(i=rows-1; i>=1; i--){ for(j=1; j<i; j++){ cout<<" ";//print space } for(j=i; j<=rows; j++){ //print lower part cout<<"*"; } cout<<"\n"; } return 0; }
When the above code is executed, it produces the following result
Enter the number ofrows: 6 ****** ***** **** *** ** * ** *** **** ***** ******
Program 4
#include <iostream> #include <conio.h> using namespace std; int main() { int rows,i,j,k; cout<<"Enter the number of rows: "; cin>>rows;//take input from user for rows for(i=1; i<=rows; i++){ //print upper part for(j=1; j<=rows-i; j++){ cout<<" "; } for(k=1; k<=i; k++){ cout<<"*";//print star to upper part cout<<" "; } cout<<"\n"; } for(i=1; i<=rows-1; i++){ //print lower part for(j=1; j<=i; j++){ cout<<" "; } for(k=1; k<=rows-i; k++){ cout<<"*";//print star to lower part cout<<" "; } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following result
Enter the number of rows: 6 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Similar post
integrated pyramid star pattern in C
integrated pyramid star pattern in Java
C++ code to Double pyramid star pattern
Java code to Double pyramid star pattern
Java program to Display diamond number pattern using while loop
C++ code to Display diamond number pattern using while loop
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
Hollow pyramid triangle pattern in C++ language
Rhombus pattern in Java using for loop
Rhombus pattern in C using while loop
Rhombus pattern in C++ using do-while loop
Display Pyramid star pattern in C
Display Pyramid star pattern in Java
Parallelogram and Hollow Parallelogram star pattern in Java
Parallelogram and Hollow Parallelogram star pattern in C Language
C++ program to Display diamond number pattern using while loop
C program to Display diamond number pattern using while loop
Suggested for you
Nested for loop in Java language
Nested for loop in C++ language
Nested for loop in Python language
If statements in Java language
Nested if statements in Java language
Nested while loop in Java language
Nested while loop in C language
Class and main method in Java language
Data type in C++ language
Nested for loop in C++ language
How to find reverse number using method In this article, we will discuss the concept…
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…