0
How does the following program output 66???
int main() { int x = 24; int y = 36; //calling the function with both parameters int result = sum(x, y); cout << result << endl; //Outputs 60 //calling the function without b result = sum(x); cout << result << endl; //Outputs 66
4 Respostas
+ 1
int sum(int a, int b=42) {
int result = a + b;
return (result);
}
The default value of b is 42.
If you call the function without b then the second parameter will have the default value
0
default value of y parameter may be 20
0
can you explain it a bit??
0
If the corresponding argument is missing when you call a function, it uses the default value.And the default value was 42,so 24 + 42=66