Floyd's triangle

C++ program to Integrated triangle patterns using for loop

C++ program to Integrated triangle patterns using for loop

In this tutorial, we will discuss a concept of  C++ program to Integrated triangle patterns using for loop

In C++  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 triangle patterns  using for loop in C++ language

C++ program to Integrated triangle star patterns

Integrated Triangle star pattern 1

Program 1

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

int main()
{
    int i,j,k,rows;
    cout<<"Enter the number of rows: ";
    cin>>rows;  //get input from user for rows
    for(i=1; i<=rows; i++){  //parent for loop
  for(j=1; j<=i; j++){
  cout<<"*";

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

}

for(k=i; k>=1; k--){
  cout<<"*";

}

  cout<<"\n";

}
getch();
    return 0;
}

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

Integrated triangle pattern

 

Integrated Triangle star pattern 2

Program 2

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

int main()
{
    int i,j,k,rows;
    cout<<"Enter the number of rows: ";
    cin>>rows;     //get input from user for rows
    for(i=rows; i>=1; i--){  //parent for loop
  for(j=rows; j>=1+rows-i; j--){
  cout<<"*";

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

}

for(k=1+rows-i; k<=rows; k++){
    if(k!=1)
  cout<<"*";

}

 cout<<"\n";

}
getch();
    return 0;
}

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

Integrated triangle pattern

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,k,rows;
    cout<<"Enter the number of rows fore pattern: ";
    cin>>rows;    //get input from user for rows
    for(i=1; i<=rows; i++){  //parent for loop
  for(j=1; j<=i; j++){
  cout<<j;

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

}

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

}

  cout<<"\n";

}
getch();
    return 0;
}

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

Integrated triangle pattern

 

 

Integrated Triangle number pattern 2

Program 2

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

int main()
{
    int i,j,k,rows;
    cout<<"Enter the number of rows: ";
    cin>>rows;   //get input from user for rows
    for(i=rows; i>=1; i--){   //parent for loop
  for(j=rows; j>=1+rows-i; j--){
  cout<<j;

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

}

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

}

 cout<<"\n";

}
getch();
    return 0;
}

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

Integrated triangle pattern

 

Integrated Triangle number pattern 3

Program 3

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

int main()
{
    int i,j,k,rows;
    cout<<"Enter the number of rows: ";
    cin>>rows;   //get input from user for rows
    for(i=rows; i>=1; i--){   //parent for loop

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

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

     for(k=i; k>=1; k--){
        if(k!=rows)
         cout<<k;
              }
cout<<"\n";

         }
         getch();
    return 0;
}

 

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

C++ program to Integrated Pyramid

 

Similar post

C  code to Integrated triangle patterns using for loop

Java  code to Integrated triangle patterns using for loop

 

Suggested for you

C++ data types

C++ variables

For loop in C++ language

Nested for loop in C++ language

Java program to Integrated triangle patterns using for loop
C program to Integrated triangle patterns using for 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…

2 months 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