Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Floyd’s triangle star patterns in C++ language using for loop

Posted on July 21, 2016June 26, 2020

Table of Contents

  • Floyd’s triangle star patterns in C++ language
    • Triangle star patterns
      • Triangle star pattern `1
      • Triangle star pattern `2
      • Triangle star pattern `3
      • Triangle star pattern `4
      • Related Article

Floyd’s triangle star patterns in C++ language

In this tutorial, we will discuss Floyd’s triangle patterns in C++ language

In this post, we will learn how to create Floyd,s triangle star pattern using for loop

In the C++ language, we can display many patterns (star, number, alphabet, binary patterns using for loop, while loop and do-while loop)

Here, we can print floyd;s triangle satr pattern using nested for loop in C++ language

Triangle star patterns

Triangle star pattern `1

Program 1

This program allows the user to enter the number of rows and then it displays the right triangle star pattern using for loop in c language

#include <iostream>
using namespace std;
int main()
{
    int i,j,rows;
    cout<<"Enter the number of rows: ";
    cin>>rows;
    for(i=1;i<=rows;++i)
    {
        for(j=1;j<=i;++j)
        {
           cout<<"* ";
        }
        cout<<"n";
    }
    return 0;
}

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

Floyd's triangle star patterns in C++ language
Pattern 1

Triangle star pattern `2

This program allows the user to enter the number of rows and then it displays the inverted right triangle star pattern using for loop in c language

Program 2

#include <iostream>
using namespace std;
int main()
{
    int i,j,rows;
    cout<<"Enter the number of rows: ";
    cin>>rows;
    for(i=rows;i>=1;--i)
    {
        for(j=1;j<=i;++j)
        {
           cout<<"* ";
        }
        cout<<"n";
    }
    return 0;
}

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

Floyd's triangle star patterns in C++ language
Pattern 2

Triangle star pattern `3

This program allows the user to enter the number of rows and then it displays the mirrored right triangle star pattern using for loop in c language

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

int main()
{
    int i,j,k,rows;
    cout << "Enter the number of rows" << endl;
    cin>>rows;
    for(i=rows; i>=1; i--){
        for(j=1; j<i; j++){
        cout<<" ";
    }

    for(k=rows; k>=i; k--){
        cout<<"*";
    }
     cout<<"\n";
    }
    getch();
    return 0;
}

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

Floyd's triangle star patterns in C++ language
Pattern 3

Triangle star pattern `4

This program allows the user to enter the number of rows and then it displays the inverted mirrored right triangle star pattern using for loop in c language

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

int main()
{
    int i,j,k,rows;
    cout << "Enter the number of rows" << endl;
    cin>>rows;
    for(i=rows; i>=1; i--){
        for(j=rows; j>i; j--){
        cout<<" ";
    }

    for(k=1; k<=i; k++){
        cout<<"*";
    }
     cout<<"\n";
    }
    getch();
    return 0;
}

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

Floyd's triangle star patterns in C++ language
Pattern 4

Related Article

Rectangle, Square and Table in Java
Pyramid Triangle in JaVa
Triangle pattern in Java
Rectangle, Square in C++
Pyramid print in C++
Rectangle, Square in C
 Triangle pattern in C
Pyramid print in C

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes