Table of Contents
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
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
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
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
#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
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
#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
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.