+2 votes
in Class 12 by kratos

What is the role of a parameter/argument passed in a function? Can a default value be assigned to a parameter(Yes/No)? If yes, justify your answer with the help of a suitable example otherwise give reason.

1 Answer

+3 votes
by kratos
 
Best answer

Parameters/arguments are values passed in the function for the attributes which are required by the function to work and provide desired output.

Yes, an argument may be assigned a default value.

E.g.

int Sum(int a, int b=10) //Here b is given a default value of 10

{ return (a+b); }

void main()

{ int x=5;

  • cout<<Sum(x);

}

Output: 15

...