Help with my homework!!!

1. Write a function that receives an integer x as an argument and print x stars in a line.
For example, if 5 is passed to the function, ***** will be the output.

2. Write a program that asks the user to enter five integers in the range from
1 to 20, and then displays the horizontal bar representation of the input
as illustrated in the example below.

User input: 12 11 4 7 17
Output:
12 ************
11 ***********
4 ****
7 *******
17 *****************

Note: Each input needs to be validated until it is in the stated range using
while-loop.
Use the function in 1 for the program,
1. try a loop
2:

1
2
3
int input[5];
readInputs(input); // implement this function
writeOutput(input); // implement this function 


Both functions will have a loop that executes five times.
The code I provide below is incomplete but more than enough for you to get started. I also provide 4 different URLs explaining everything you need to know in order to successfully write this program.

http://www.cplusplus.com/doc/tutorial/control/
http://www.cplusplus.com/reference/iostream/cin/
http://www.cplusplus.com/reference/iostream/cout/
http://www.cplusplus.com/doc/tutorial/variables/

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

int main()
{
	int UserInput = 0;

	std::cin >> UserInput;

	for ( int i = 0; i < UserInput; i ++ )
		std::cout << "*";

	return EXIT_SUCCESS;
}
Topic archived. No new replies allowed.