Needs help in logic

Hi guys: Can any one please help me how to i print the * in that order that first it print one then two and then three. I try it first but made mistakes as its printing three in each row

Output required
*
**
***

#include <iostream>
using namespace std;

int main()
{
      for (int row = 1; row < 4; row +=1)
      {
            for(int asterisks = 1; asterisks <= 3; asterisks +=1)
                  cout << '*';
      cout << endl;
      }
      system("pause");
      return 0;
}
mustish1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TommySzalapskiConnect With a Mentor Commented:
See how that works? As row gets higher, now the max value gets lower.
0
 
TommySzalapskiCommented:
change asterisks <= 3 to asterisks <= row
0
 
mustish1Author Commented:
Thanks. just last thing how to i reverse it means
***
**
*
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
TommySzalapskiCommented:
replace asterisks <= row with asterisks <= (4-row)
0
 
phoffricConnect With a Mentor Commented:
It may be a little less confusing if you define a function, print_row_of_asterisks(int numberOfAsterisks), and just call that function in a single loop. The loop inside the function should then be easy to figure out.

Also, the code will look a lot cleaner.
0
 
mustish1Author Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.