1.

“Initialized formal arguments are called default arguments.” Using this concept write the function prototype and definition of a user defined function Sum() which accepts two or three integer numbers and returns their sum.

Answer»

#include

using namespace std;

int sum(int x=100,int y=50,int z=10)

{

retum(x+y+z);

}

int main( )

{

cout<<sum()<<endl; cout<<sum(1)<<endl;

cout<<sum(1,2)<<endl;

cout<<sum(1,2)<<endl;

}



Discussion

No Comment Found