C++ Programming

 

Calculating Average

Program to calculate Average of five numbers entered by the user at runtime


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;
}

 


DISCLAIMER

Paked and the contributors are not responsible for any errors contained and are not liable for any damages resulting from the use of this material.  (Disclaimer)

 

 

Home     Disclaimer     Advertise      Contact us     

Copyright © 2006-08 Paked.com. All rights reserved.

Note: Site best viewed at 1024 x 768 or higher screen resolution

 

footer image footer image