please help with my print star assignment

Hi I'm new to programming and really need some help with my assignment
So, this is the prompt:

Modify this main program so that it prints:
*
**
***
****
***** ****** ******* ******** ********* **********
Write your program so that it's easy to change the height of the triangle.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* Tests function printStars by printing a triangle of stars. */
#include <iostream>
using namespace std;
void printStars (int numStars);
/* Prints "numStars" stars to the screen, followed by a <return>. */
main () {
  printStars(3);
  printStars(2);
  printStars(1);
}
void printStars (int numStars) {
/* Prints "numStars" stars to the screen, followed by a <return>. */
int count;
  for (count = 0; count <numStars; count ++) {
     cout<<"*";
}
  cout<<endl;
}

I've been struggling with this assignment for a while, any suggestion would be really appreciated
printStars(n) prints a line with n stars on it. So to print the the triangle, you need to call printStars(1), then printStars(2).... to printStars(10). To make it easy to change the height, put the calls to printStars() in a loop.

This is an example of using one function as a building block for another.
your printStars function looks good. You should make a loop in your main function to print out the stars based on how high the user wants the triangle.

main(){

cout<<"How many rows do you want?";
int n;
cin>>n;

for(int i=1; i<=n; i++)
printStars(i);

}
Thanks @dhayden and @manutd636 for the help! Problem solved.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;

int main()
{
int sides;
cout<<"please input the number of sides: ";
	cin>>sides;
	for(int i=1;i<=sides;i++){
		for(int j=1;j<=i;j++){
			cout<<"* ";
		}
		cout<<"\n";
	}
	return 0;
}

just as a reminder, this code can also be easily solved within main function.
but the function is pretty cool too
Topic archived. No new replies allowed.