Write a C++ program to print inverted right angled triangle star pattern using for loop.
#include<iostream> using namespace std; int main() { int i, j, rows; cout << "Enter Inverted Right Triangle Star pattern Rows = "; cin >> rows; cout << "Inverted Right Angled Triangle Star Pattern\n"; for(i = rows; i > 0; i--) { for(j = 0; j < i; j++) { cout << "*"; } cout << "\n"; } return 0; }
This C++ example example prints the inverted right angled triangle of a given character using a while loop.
#include<iostream> using namespace std; int main() { int i, j, rows; char ch; cout << "Enter Inverted Right Triangle Star pattern Rows = "; cin >> rows; cout << "Enter Symbol for Inverted Right Triangle pattern = "; cin >> ch; cout << "Inverted Right Angled Triangle Star Pattern\n"; i = rows; while( i > 0) { j = 0; while( j < i) { cout << ch; j++; } cout << "\n"; i--; } return 0; }
Enter Inverted Right Triangle Star pattern Rows = 16
Enter Symbol for Inverted Right Triangle pattern = @
Inverted Right Angled Triangle Star Pattern
@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@
@@@@@@@@@
@@@@@@@@
@@@@@@@
@@@@@@
@@@@@
@@@@
@@@
@@
@