Computer Science, asked by ak10063, 1 year ago

WAP in C for Default Argument Function.​

Answers

Answered by mehvish61
2
#include

using namespace std;


// A function with default arguments, it can be called with
// 2 arguments or 3 arguments or 4 arguments.

int sum(int x, int y, int z=0, int w=0)
{

return (x + y + z + w);
}


/* Driver program to test above function*/

int main()
{

cout << sum(10, 15) << endl;

cout << sum(10, 15, 25) << endl;

cout << sum(10, 15, 25, 30) << endl;

return 0;
}






Output:

25
50
80
Similar questions