Number pattern

C++ Program to display integrated pyramid number pattern using while loop

C++ program to display integrated pyramid number pattern using while loop

In this tutorial, we will discuss a concept of  C++ program to display integrated pyramid number pattern using while loop

In the C++ programming  language, we can use for loop ,while loop and do-while loop to display different number (binary, decimal), alphabets or star pattern programs.

In this article, we are going to learn  how to Display integrated pyramid number pattern using while loop  in C++ language

C++ code to Integrated triangle number patterns

Integrated Triangle number pattern 1

Program 1

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int i,j,row;
    cout<<"Enter the number of rows: ";
    cin>>row;//gets input from the user
    cout<<"\n";
    i=1;
while(i<=row){//print upper part
    j=i;
    while(j<=row){
        cout<<j;//print number
        j++;
    }
    i++;
    cout<<"\n";//move to next line
}

i=row-1;
while(i>=1){//print lower part
    j=i;
    while(j<=row){
        cout<<j;//print number
        j++;
    }
    i--;
    cout<<"\n";//move to next part
}
getch();
    return 0;
}

When the above code is executed, it produces the following results

integrated pyramid pattern 1

 

Integrated Triangle number pattern 2

Program 2

#include <iostream>
#include <conio.h>
using namespace std;
    int main()
{
    int i,j,row;//variable declaration
    cout<<"Enter the number of rows: ";
    cin>>row;//get input from user
    cout<<"\n";
i=1;
while(i<=row){//print upper part
    j=1;
while(j<i){
    cout<<" ";//print space
    j++;
}
j=i;
    while(j<=row){
        cout<<j;
        j++;
    }
    i++;
    cout<<"\n";
}

i=row-1;
while(i>=1){//print lower part
    j=1;
while(j<i){
    cout<<" ";//print space
    j++;
}
j=i;
    while(j<=row){
        cout<<j;//print number
        j++;
    }
    i--;
    cout<<"\n";
}
getch();
    return 0;
}

When the above code is executed, it produces the following results

pyramid number pattern 2

 

Integrated Triangle number pattern 3

Program 3

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{

    int i,j,row;
    cout<<"Enter the number of rows: "<< endl;
    cin>>row;//gets input from user
    cout<<"\n";
    i=1;
while(i<=row){//print upper part
    j=1;
while(j<=i){
    cout<<" ";
    j++;
}
j=i;
    while(j<=row){
        cout<<j;
        cout<<" ";
        j++;
    }
    i++;
    cout<<"\n";
}

i=row-1;
while(i>=1){
    j=1;
while(j<=i){
    cout<<" ";
    j++;
}
j=i;
    while(j<=row){
        cout<<j;
        cout<<" ";
        j++;
    }
    i--;
    cout<<"\n";
}
getch();
return 0;

}

When the above code is executed, it produces the following results

integrated pyramid number pattern 3

 

Integrated Triangle number pattern 4

Program 4

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int i,j,row;
    cout<<"Enter the number of rows\n";
    cin>>row;//gets input from user
     cout<<"\n";
    i=1;
while(i<=row){//print upper part
    j=1;
while(j<=row-i){
     cout<<" ";
    j++;
}
j=1;
    while(j<=i){
         cout<<j;
         cout<<" ";
        j++;
    }
    i++;
     cout<<"\n";
}

i=1;
while(i<=row-1){
    j=1;
while(j<=i){
     cout<<" ";
    j++;
}
j=1;
    while(j<=row-i){
         cout<<j;
         cout<<" ";
        j++;
    }
    i++;
     cout<<"\n";
}
getch();
    return 0;
}

When the above code is executed, it produces the following results

Integrated pyramid number pattern 4

 

Integrated Triangle number pattern 5

Program 5

#include <iostream>
#include <conio.h>
using namespace std;

int main(){
int i,j,k,rows;
    cout<<"Enter the number of rows\n";
    cin>>rows;//gets input from user
    cout<<"\n";

    i=1;
while(i<=rows){
        j=1;
  while(j<=i){
  cout<<j;
   j++;
}

j=i*2;
while(j<rows*2){
  cout<<" ";
   j++;
}

k=i;
while( k>=1){
  cout<<k;
   k--;
}

  cout<<"\n";

   i++;

}
getch();
    return 0;
}

When the above code is executed, it produces the following results

Integrated pyramid number pattern 5

 

Integrated Triangle number pattern 6

Program 6

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int i,j,k,rows;
    cout<<"Enter the number of rows\n"<<endl;
    cin>>rows;//gets input from user
    cout<<"\n";

    i=rows;
while(i>=1){
j=1;
     while(j<=i){
         cout<<j;
          j++;
             }
j=i*2;
     while( j<rows*2-1){
         cout<<" ";
          j++;
            }
k=i;;
     while( k>=1){
        if(k!=rows)
         cout<<k;
          k--;
              }
cout<<"\n";
 i--;
         }
         getch();
         return 0;
}

When the above code is executed, it produces the following results

Integrated pyramid number pattern 6

 

Integrated Triangle number pattern 7

Program 7

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int i,j,k,rows;
    cout<<"Enter the number of rows\n";
    cin>>rows;//gets input from user
    cout<<"\n";

    i=rows;
while(i>=1){//print upper part
j=1;
     while(j<=i){
         cout<<j;

          j++;
             }
              cout<<"\n";
             i--;
}
i=1;
     while( i<rows){//print lower part
         j=1;
         while(j<=i){
         cout<<j;

          j++;
             }
             cout<<"\n";

          i++;
         }
         getch();
    return 0;
}

When the above code is executed, it produces the following results

Integrated pyramid number pattern 7

 

Integrated Triangle number pattern 8

Program 8

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
     int i,j,k,rows;
    cout<<"Enter the number of rows\n"<<endl;
    cin>>rows;//gets input from user
    cout<<"\n";

    i=rows;
while(i>=1){  //parent while loop
    j=rows;
  while(j>=1+rows-i){
  cout<<j;

   j--;

}
     j=i*2;
    while(j<rows*2-1){
  cout<<" ";
  j++;

    }

    k=1+rows-i;
    while( k<=rows){
    if(k!=1)
  cout<<k;
 k++;

   }

  cout<<"\n";
  i--;

}
getch();
    return 0;
}

When the above code is executed, it produces the following results

Integrated pyramid number pattern 8

 

Similar post

Java program to display integrated pyramid number pattern using while loop

C program to display integrated pyramid number pattern using while loop

 

 

Suggested for you

Data types  in C++ language

Variable in C++ language

While loop in  C++  language

Nested while loop in C++ language

Operator in C++ language

 

 

 

 

C program to display integrated pyramid number pattern using while loop
Program to display integrated pyramid number pattern in Java using while loop
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