ExamVeda
Login
Home
11
What is the output of the following code: int square(int x) { return x * x; } int main() { cout << square(3) + square(2); } in C++?
Discuss
Answer & 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.

12
What is the correct syntax for defining a recursive function in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
13
What is the purpose of a function header in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
14
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++?
Discuss
Answer & 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.
15
Which of the following is true about function recursion in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
16
What is the purpose of a function in C++?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
17
Which of the following is true about function parameters in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
18
What is the correct way to declare a function in C++ that takes no parameters and returns an integer?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
19
What is the purpose of the 'void' keyword in a function declaration in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
20
What is the output of the following code: int multiply(int x, int y) { return x * y; } int main() { cout << multiply(3, 4); } in C++?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board