I need a while loop that calculates the min, max and average of n numbers.

Write your question here.
Basically the user is told "Enter N" Then my program will allow the user to enter the following N integers, one at a time. After the user has input all N integers your program will output the following:
* The maximum value (int) of all entered integers

* The minimum value (int) of all entered integers

* Their average value (double) of all entered integers. This average value carries TWO (2) decimal precision.
Output should look like this:
Please enter N: 4
Integer #1: 2
Integer #2: -34
Integer #3: 344
Integer #4: 3
Max: 344
Min: -34
Average: 78.75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #include <iostream>

using namespace std;

int main()
{

int N=10; 
int userS;
std::cout << "Please enter N: ";
std::cin >> N; 
std::string phrase = "Integer # "; 
while (int count=0); count<N; ++count) std::cout << phrase 
  << (1 + count) << ":\n";
 
 
 
   
   return 0;
}
You didn't ask a question, but allow me to correct your code so it at least compiles:

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 main()
{
    int N=10; 
    int userS;
    std::cout << "Please enter N: ";
    std::cin >> N; 
    std::string phrase = "Integer # "; 

    for (int count = 0; count < N; ++count )
    {
        std::cout << phrase << 1+count << ":\n" ; 
    }

   return 0;
}

Here is your while loop and a little more:
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
#include <iostream>
#include <string>
#include <limits.h>

using namespace std;

int main()
{
  int N = 0, max = INT_MIN, min = INT_MAX, sum = 0; 
  float average = 0.0;

  std::cout << "Please enter N: ";
  std::cin >> N; 
  std::string phrase = "Integer # ";

  int count = 0, number;
  while (count++ < N)
  {
    std::cout << phrase << count << '\t';
    std::cin >> number;

    // Process the input i.e. number here
  }
  return 0;
}
Topic archived. No new replies allowed.