Q11
What is the output of the following code: int square(int x) return x * x; int main() cout << square(3) + square(2); in C++?
A.
13
AnswerB.
25
C.
12
D.
Compilation error due to mismatched return types
Answer: Option A
Solution
Answer: Option A
Solution:
The given code defines a function named square which takes an integer x as input and returns the square of x. In the main function, square(3) returns 9 and square(2) returns 4. When these values are added together and printed, the output will be 9 + 4 = 13.