|
|
|
|
Calculating AverageBinary Search | Bubble Sort | Selection Sort | Finding Maximum Value | Linear Search | Celsius to Fahrenheit | 10 Pseudo-random numbers | Calculating Average | Swapping Values | Lowercase/ Uppercase Program to calculate Average of five numbers entered by the user at runtime C++ Source Code #include <iostream.h>
// This program calculates the average
// of five user-entered numbers.
int main()
{
const int MAXCOUNT = 5;
int count;
float num, total, average;
total = 0.0;
for (count = 0; count < MAXCOUNT; count++)
{
cout << "Enter a number: ";
cin >> num;
total = total + num;
}
average = total / count;
cout << "The average of the data entered is " << average << endl;
return 0;
}
Copyrights Gary Bronson. "A First Book of C++: From Here to There " Thomson Learning. |
|
|
|