1.

Write a function that accept 3 numbers of type float as argument and return the average of three numbers. Write program which use this function to find the average of three numbers using C++.

Answer»

# include

using namespace std;

float avg(float n1 , float n2 , float n3)

{

return ((n1 + n2 + n3)/3);

}

int main( )

{

float x, y, z;

cout<<"Enter 3 nos”; cin>> x>>y>>z;

cout<<“the average is”<<avg(x,y,z);

}



Discussion

No Comment Found