I'm making a program which outputs the min, max and average for any specified user input of numbers, for example a sample output would be:

Enter a choice (0 for max, 1 for min, 2 for avg, 3 to quit): 1
How many numbers?: n numbers
Enter n numbers: 1 , 2, 3 ,4..etc
Min is : __

my flowchart is logical as of right now, but i cannot figure out how to correspond how many numbers? a user chooses to enter to then entering that amount of numbers.

I was thinking something like this for coding (just some of the body):
int main() {

int count = 0;
int choice;
int nums;
etc...

cout << "Enter a choice: "
cin >> choice;

while (cin)
count = count + 1

cout << "How many numbers?: ";
cin >> count;
cout << "Enter " << count << "numbers:";
cin >> nums;

I know this isnt correct, but i cannot figure out the logic on how to set a user specified amount of numbers.

Ex- How many numbers: 7
Enter 7 numbers:

Maybe you could allocate an array and pass it together with an int telling the size of the array?

Maybe you could allocate an array and pass it together with an int telling the size of the array?

i have though about something like that, but we haven't covered arrays in my class yet, so he expects while statements and if statements

``````int nums;
cout << "How many numbers do you want to enter?: ";
cin >> nums;
cout << "Enter " << nums << "numbers:";
for(int count = 0; count < nums; ++count)
{
cout << "enter number # "  << count + 1 << endl;
cin >> num;
}``````

After second thought an array wouldn't do it very well.

``````int arg;
cin >> arg;
int largest = arg;
for(int i=1; i<count; i++)
{
cin >> arg;
if(largest < arg)
largest = arg;
}``````

Do you understand the code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.