I need to write a program that would read in numbers from the keyboard, compute the average of the numbers, and display it. The sequence of numbers are to be terminated with a zero.
Here is my code:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int count;
double number, sum, average;
count = 0;
sum = 0;
average = 0;
cout << "\nEnter Number (0 to terminate): ";
cin >> number;
while(number! = 0.0)
{
sum = sum + number;
count = count + 1;
cout << "\nEnter Number: ";
cin >> number;
}
if(count! = 0.0);
{
average = sum/count;
}
cout << "\nThe average of the" << count << "number is" << average << endl;
return 0;
}
However, I am getting two errors:
expected ')'
and
if statement has empty body