Need Help Adding Loops

#include <iostream>
using namespace std;

int main()
{
int num;

cout << endl << "Enter numbers, 999 to quit" << endl;
cin >> num;
while (num != 999)
{
cout << "Number entered is: " << num << endl;
cout << "Enter numbers, 999 to quit" << endl;
cin >> num;
}
return 0;
}

1. Add the steps to total the numbers entered.
2. Add the steps to count how many numbers were entered.
3. Add the steps to compute the average.
If you're not using a container class like vectors or arrays, you're gonna need a few counters.

You might also find something like this to be useful:
1
2
3
4
5
6
7
int sum = 0;
while( /*!condition*/ ) 
{ 
    sum += num; 
    ++numCounter;
}
average /= numCounter;


EDIT: accidentally'd a curly brace
Last edited on
Topic archived. No new replies allowed.