Floyd Triangle Pattern Program in C++ language
ADVERTISEMENTS
Floyd triangle pattern program in c++ language. In this article, you will learn how to print the floyd triangle pattern program in c++ language.
Source Code
// Floyd Triangle Pattern Program in C++ language
#include <iostream>
using namespace std;
int main() {
int r, i, j, n = 1;
// r - denotes the number of rows
cout << "-----Kindly enter the number of rows to print Floyd's triangle number pattern-----\n";
cin >> r;
cout << "\n-----This is Floyd's triangle number pattern-----\n\n";
for (i = 1; i <= r; i++) {
cout << "\t";
for (j = 1; j <= i; ++j) {
cout << n << " ";
++n;
}
cout << "\n";
}
return 0;
}
Output
-----Kindly enter the number of rows to print Floyd's triangle number pattern-----
5
-----This is Floyd's triangle number pattern-----
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15