
234 Functions in C++
cout<<“\n Enter float values for fa,fb and fc: ”;
cin>>fa >>fb >>fc;
id=add();
cout<<“\n Addition: ” <<id;
fd= add (fa,fb,fc);
cout<<“\n Addition: ”<<fd;
return 0;
}
add ( )
{
int x;
x=add(fa,fb,fc);
return (x);
}
float add (float a, float b, float c )
{
return (a+b+c);
}
OUTPUT
Enter float values for fa,fb and fc : 5.5 2.4 8.2
Addition : 16
Addition : 16.1
Explanation: In the above program, the function add() is overloaded. The add(void) function
does not require any argument but returns integer. The float add() function requires three argu-
ments of float type. Here, the arguments are fa, fb, fc, fd, and id and are declared