Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Pattern/pattern8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Printing the inverted triangle pattern using for loop.

#include <iostream>
using namespace std;

void printInvTriangle(int n)
{

for (int i = 0; i < n; i++) {

int space = i;


for (int j = 0; j < 2 * n - i - 1; j++) {

if (space) {
cout << " ";
space--;
}
else {
cout << "* ";
}
}
cout << endl;
}
}

int main()
{
printInvTriangle(5);

return 0;
}

Output

* * * * * * * * *
* * * * * * *
* * * * *
* * *
*