WAP C++ to left side star pattern
*
**
***
****
*****
Code:-
#include <iostream>
using namespace std;
int main()
{
for(int i=1;i<=5;i++){ //outer For loop
for(int j=1;j<=i;j++){ //inner For loop
cout<<"*";
}
cout<<endl;
}
return 0;
}
Explanation of this program:-
- The outer for loop that manages the pattern's number of rows is 'for(int i = 1; i = 5; i++)'. It will produce 5 rows in the pattern because it iterates from 'i = 1' to 'i = 5'.
- 'for (j = 1, j <= i, j++)' The inner for loop that prints stars in each row is the one that does this. The value of i defines how many symbols are printed in a row. For instance, it will print one star in the first row '(i = 1)', two stars in the second row '(i = 2)', and so on.
- Every time the inner loop repeats, the statement 'cout <<"*";' prints a star.
- 'cout<<endl;' This line is used to advance to the following line after the inner loop for printing asterisks in a row is complete, producing the new line result and the right-angled triangle pattern.