Having trouble with my first C++ problem

Hello for my homework assignment I am required to do the following:
Ask the user to enter a number between 20 and 100.
Continue asking until it is valid.
Use that number to generate that number of random numbers and store it in an array.
Then display the numbers up to 10 per line, average of the numbers, the highest value, the lowest value, the range, and standard deviation.

I have never worked with arrays so that is where I am having most of my issues.
Here is where I am so far.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 #include <iostream>
using namespace std;

Int number = 0;
Int count = 0;
Float average = 0;
Int largest = -1;
Int smallest = -1;

Do
{
	Cout << “Please enter a number between 20 and 100: “;
	Cin >> number;”
	While (number < 20 || number > 100);
	{
		Cout << “The number must be between 20 and 100./n “;
		Cout << “Please enter a number between 20 and 100: “;
Cin >> number;
}	
I have never worked with arrays so that is where I am having most of my issues.


So you should first read up on arrays: http://www.cplusplus.com/doc/tutorial/arrays/
closed account (LNboLyTq)
Hi kevcpp,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;

Int number = 0;
Int count = 0;
Float average = 0;
Int largest = -1;
Int smallest = -1;

Do
{
	Cout << “Please enter a number between 20 and 100: “;
	Cin >> number;”
	While (number < 20 || number > 100);
	{
		Cout << “The number must be between 20 and 100./n “;
		Cout << “Please enter a number between 20 and 100: “;
Cin >> number;
}


I don't think this is a valid C++ code, and it is also not pseudo-code.
What I pay attention to is (“). C++ uses double-quotation mark (") not (“)

Please be sure you have your working program first before you can work on arrays.

Hope this helps,
Andy
Last edited on
Sorry I think that is because I copied and pasted it from a word document. I was using a school computer at the time that did not have the software I needed.
Hello, not sure if you figured it out yet but the way I would do it would be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
using namespace std;

Int number = 0;
Int count = 0;
Float average = 0;
Int largest = -1;
Int smallest = -1;

int main()
{

	cout << “Please enter a number between 20 and 100: “;
	cin >> number;

	while (number < 20 || number > 100)
	{
		cout << “The number must be between 20 and 100./n “;
		cout << “Please enter a number between 20 and 100: “;
                cin >> number;
         }

}


Hope this helps!
and please, no capitals in ANY c++ codes

or it will not work. example like this,

Int hi=89;

int cannot be Int.
Topic archived. No new replies allowed.