#include <iostream>
#include <cmath> // This is simply a library of math functions we can use.
using namespace std;
void Average(int value1, int value2, int value3, int value4)
{
((value1 + value2 + value3 + value4)/4);
}
int main()
{
int value1,value2,value3,value4;
double average;
cout << "We are going to take the average of four values. Please type 4 numbers you would like to take the average of.\n";
cin >> value1 >> value2 >> value3 >> value4;
cout << "The average is " << Average(value1, value2, value3, value4) << endl;
}
Im not sure how to put tags around my code for this site, but I tried. Anyway I just want to create a function for averaging 4 numbers. In other words, I am relying on #include <cmath> so that I can use the functions. Problem is when I run this program, theirs errors, and I am not sure why. What is wrong with this code?
This post has been edited by Oler1s: 24 June 2012 - 02:00 PM
Reason for edit:: It's /code, not \code

New Topic/Question
Reply



MultiQuote









|