diff --git a/Pattern/pattern8.md b/Pattern/pattern8.md new file mode 100644 index 0000000..d93fe2b --- /dev/null +++ b/Pattern/pattern8.md @@ -0,0 +1,41 @@ +Printing the inverted triangle pattern using for loop. + +#include +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 + +* * * * * * * * * + * * * * * * * + * * * * * + * * * + * \ No newline at end of file