This program kinda works, but I have one problem. I setup this program to display a message when someone enters a negative number, but I how do I set the count back to zero. Even though mesage prompts the user that a negative number is invalid, it still calculates the number in the average. Please help
#include <iostream>
using namespace std;
int main()
{
// Variables
const int positive_numbers = 10;
int numbers[positive_numbers];
double average;
double sum = 0.0;
int num;
//Read all numbers
for (int i = 0; i < positive_numbers; i++)
{
cout << "Enter a number: ";
cin >> num;
if( num < 0 ) cout << "Invalid! Please enter a number greater than or equal to zero." << endl;
numbers[i] = num;
sum += numbers[i];[/B]
}
//Find the average
average = sum/10;
// Display average
cout <<"\nThe average is " << average <<"\n\n";
return 0;
}