Void Programming Question

void printStars(int);/*( ADD:) the function prototype for printStars */

int main()
{
int numofstars;

cout << "Enter the number of stars in the first line: " << endl;
cin >> numofstars;

while (numofstars > 0)
{

printStars(numofstars);/*( ADD): code to invoke function *printStars* */
int numofstars;/* (ADD:) code to update the control variable *numOfStars* */

}

return 0;
}

//****************************************************************************

void printStars(int num)
{
while (num<=0)
{
cout << "*";
num++;
}

// } /*( ADD:) code to print the *num* of stars in a line by using a loop*/
}

So I am new to programming and just really confused what to do, all I have to do is add code besides the " ADD;" I have tried but I am doing somthing wrong , I think I got the First "ADD"
correct on the top but other Im consfused , please help me thanks.
Last edited on
Imagine numofstars == 5.
How should the output look like ?
This may or may not be what is required:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;

void printStars(int);

int main()
{
	int numofstars {};

	cout << "Enter the number of stars in the first line: " << endl;
	cin >> numofstars;

	while (numofstars > 0)
	{
		printStars(numofstars);
		cout << '\n';
		--numofstars;
	}

	return 0;
}

//****************************************************************************

void printStars(int num)
{
	while (num > 0) {
		cout << "*";
		--num;
	}
}




Enter the number of stars in the first line:
6
******
*****
****
***
**
*


but if a different output is required, then the loop(s) will need to be adjusted.

Wow thanks !
Topic archived. No new replies allowed.