#include <iostream>
using namespace std;
double average(int x);
int main()
{
    int a,b,c;
    cout <<"average is:"<<average(a,b,c);
    cin >>a>>b>>c;
    return 0;
}

double average(int x)
{
  return (x+x+x)/3;
}
int a,b,c;
cout <<"average is:"<<average(a,b,c);
cin >>a>>b>>c;

I always wonder how it makes sense to do the work before getting the values when the work depends on the values. Try this:

int a,b,c;
cin >>a>>b>>c;
cout <<"average is:"<<average(a,b,c);

Also, the function is not defined to take 3 arguments. This will fit your call better:

double average(int x, int y, int z)
{
    return (x+y+z)/3;
}

help you fix what??? The most obvious problem is that it is using uninitialized variables a, b and c. Next, function average only takes one argument, not 3. Either change that function to accept three arguments or only pass one.

[edit]^^^ what Tom said. [/edit]

Where you go

#include <iostream>
using namespace std;
double average(int,int,int);
int main()
{
	int a,b,c;	
	cin >>a>>b>>c;
	cout <<"average is:"<<average(a,b,c) << endl;
	return 0;
}

double average(int x,int y, int z)
{
	return (x+y+z)/3.0;
}

hi.. please try this one.. im not sure if this is what you wanted but i hope this code can help you..

#include<iostream>
using namespace std;

int main()
{
float a,b,c;
double x;
// x = average of a,b,c

cout<<"Insert 3 Average: "
cin>>a;
cin>>b;
cin>>c;

x = (a+b+c)/3;

cout<<"The average is "<<x;

return 0;
}

™Thug Line™

commented: Learn to use code tags. -7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.