VB icon

Averaging Program

Email
Submitted on: 1/7/2015 6:48:00 PM
By: john Fivekiller (from psc cd)  
Level: Beginner
User Rating: By 2 Users
Compatibility: C, C++ (general)
Views: 876
 
     To make the task of averaging out numbers easy by using my programing skills
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Averaging Program
// Description:To make the task of averaging out numbers easy by using my programing skills
// By: john Fivekiller (from psc cd)
//
// Assumes:It accepts only floating point numbers
//
// Side Effects:Has not been debugged side effects unknown
//**************************************

#include <iostream.h>
#include <stdlib.h>
float average(int number, float total)
{
float average;
average = total / number;
return average;
}
int getnumber(void)
{
int number;
cout<<"Enter the total numbers\n";
cin>>number;
return number;
}
float getallnumbers (int amount)
{
float input;
int i = 0;
cout<<"Enter All number to be divided\n";
float allnumbers = 0.0;
while (i < amount)
{
cin>>input;
allnumbers = allnumbers + input;
amount--;
}
return allnumbers;
}
using namespace std;
int main(int argc, char *argv[])
{
int number;
 number=getnumber();
float total;
 total=getallnumbers(number);
float theaverage;
 theaverage=average(number,total);
 cout<<"The average of the numbers are "<<theaverage<<endl; 
 system("PAUSE");	
 return 0;
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.