Vidyalelo
C++ Programming · Q14

Functions and Procedures in C++

Programming · C++ Programming · question 14

Q14

What will be the output of the following code: int max(int a, int b) return (a > b) ? a : b; cout << max(5, 3); in C++?

A.
max(5, 3)
Answer
B.
3
C.
Compilation error due to missing function definition
D.
max(3, 5)

Answer: Option A

Solution

Answer: Option A
Solution:
The given code defines a function named max which takes two integers a and b as input and returns the maximum of the two. In the main function, max(5, 3) is called, but it is directly printed to the output without any calculation. Therefore, the output will be max(5, 3), representing the function call.