Functions And Procedures In C Plus Plus — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Functions And Procedures In C Plus Plus — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int square(int x) { return x * x; } int main() { cout << square(3) + square(2); } in C++?
Correct Answer: Option A — 13
Detailed Academic Explanation:
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 .
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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++?
Correct Answer: Option A — max(5, 3)
Detailed Academic Explanation:
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.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax for defining a function in C++?
Correct Answer: Option A — returnType functionName(parameters) { body; }
Detailed Academic Explanation:
returnType functionName(parameters) { body; } is the correct answer to “What is the correct syntax for defining a function in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of a function prototype in C++?
Correct Answer: Option D — Declares the function before it is defined
Detailed Academic Explanation:
Declares the function before it is defined is the correct answer to “What is the purpose of a function prototype in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to define a function in C++ that does not return any value?
Correct Answer: Option C — void
Detailed Academic Explanation:
void is the correct answer to “Which keyword is used to define a function in C++ that does not return any value”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to call a function named "add" that takes two parameters in C++?
Correct Answer: Option B — add(int a, int b)
Detailed Academic Explanation:
add(int a, int b) is the correct answer to “What is the correct way to call a function named "add" that takes two parameters in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'return' statement do in a function in C++?
Correct Answer: Option B — Returns a value from the function
Detailed Academic Explanation:
Returns a value from the function is the correct answer to “What does the 'return' statement do in a function in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int sum(int a, int b) { return a + b; } cout << sum(3, 5); in C++?
Correct Answer: Option C — 8
Detailed Academic Explanation:
8 is the correct answer to “What is the output of the following code: int sum(int a, int b) { return a + b; } cout << sum(3, 5); in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is true about function overloading in C++?
Correct Answer: Option D — Multiple functions can have the same name with different parameters
Detailed Academic Explanation:
Multiple functions can have the same name with different parameters is the correct answer to “Which of the following is true about function overloading in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of default arguments in C++ functions?
Correct Answer: Option A — Allows a function to be called without providing all arguments
Detailed Academic Explanation:
Allows a function to be called without providing all arguments is the correct answer to “What is the purpose of default arguments in C++ functions”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax for declaring a function prototype in C++?
Correct Answer: Option A — returnType functionName(parameters)
Detailed Academic Explanation:
returnType functionName(parameters) is the correct answer to “What is the correct syntax for declaring a function prototype in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of passing arguments by reference in C++ functions?
Correct Answer: Option D — Allows changes made to the arguments to reflect outside the function
Detailed Academic Explanation:
Allows changes made to the arguments to reflect outside the function is the correct answer to “What is the purpose of passing arguments by reference in C++ functions”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax for defining a recursive function in C++?
Correct Answer: Option A — returnType functionName(parameters) { functionName(parameters); }
Detailed Academic Explanation:
returnType functionName(parameters) { functionName(parameters); } is the correct answer to “What is the correct syntax for defining a recursive function in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of a function header in C++?
Correct Answer: Option C — Declares the name, return type, and parameters of the function
Detailed Academic Explanation:
Declares the name, return type, and parameters of the function is the correct answer to “What is the purpose of a function header in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is true about function recursion in C++?
Correct Answer: Option C — A function calling itself directly or indirectly
Detailed Academic Explanation:
A function calling itself directly or indirectly is the correct answer to “Which of the following is true about function recursion in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of a function in C++?
Correct Answer: Option D — To perform a specific task
Detailed Academic Explanation:
To perform a specific task is the correct answer to “What is the purpose of a function in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is true about function parameters in C++?
Correct Answer: Option A — They are variables used to pass data into functions
Detailed Academic Explanation:
They are variables used to pass data into functions is the correct answer to “Which of the following is true about function parameters in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to declare a function in C++ that takes no parameters and returns an integer?
Correct Answer: Option D — int functionName()
Detailed Academic Explanation:
int functionName() is the correct answer to “What is the correct way to declare a function in C++ that takes no parameters and returns an integer”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'void' keyword in a function declaration in C++?
Correct Answer: Option C — Indicates that the function does not return a value
Detailed Academic Explanation:
Indicates that the function does not return a value is the correct answer to “What is the purpose of the 'void' keyword in a function declaration in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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++?
Correct Answer: Option B — 12
Detailed Academic Explanation:
12 is the correct answer to “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++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a valid function declaration in C++?
Correct Answer: Option D — int sum(int a, int b)
Detailed Academic Explanation:
int sum(int a, int b) is the correct answer to “Which of the following is a valid function declaration in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of function overloading in C++?
Correct Answer: Option A — Allows multiple functions with the same name but different parameters
Detailed Academic Explanation:
Allows multiple functions with the same name but different parameters is the correct answer to “What is the purpose of function overloading in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'inline' keyword do in C++ function declaration?
Correct Answer: Option D — Suggests the compiler to replace the function call with its definition
Detailed Academic Explanation:
Suggests the compiler to replace the function call with its definition is the correct answer to “What does the 'inline' keyword do in C++ function declaration”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int max(int a, int b) { return (a > b) ? a : b; } int main() { cout << max(5, 5); } in C++?
Correct Answer: Option C — 5
Detailed Academic Explanation:
5 is the correct answer to “What is the output of the following code: int max(int a, int b) { return (a > b) ? a : b; } int main() { cout << max(5, 5); } in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C++, how are function arguments passed by default?
Correct Answer: Option B — By value
Detailed Academic Explanation:
By value is the correct answer to “In C++, how are function arguments passed by default”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'static' keyword in a function declaration in C++?
Correct Answer: Option B — It restricts the scope of the function
Detailed Academic Explanation:
It restricts the scope of the function is the correct answer to “What is the purpose of the 'static' keyword in a function declaration in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for defining a recursive function in C++?
Correct Answer: Option D — returnType functionName(parameters) { functionName(parameters); }
Detailed Academic Explanation:
returnType functionName(parameters) { functionName(parameters); } is the correct answer to “What is the syntax for defining a recursive function in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: int add(int x, int y) { return x + y; } int main() { cout << add(2); } in C++?
Correct Answer: Option C — Compilation error due to missing argument
Detailed Academic Explanation:
Compilation error due to missing argument is the correct answer to “What will be the output of the following code: int add(int x, int y) { return x + y; } int main() { cout << add(2); } in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'extern' keyword in a function declaration in C++?
Correct Answer: Option D — It specifies that the function is defined elsewhere
Detailed Academic Explanation:
It specifies that the function is defined elsewhere is the correct answer to “What is the purpose of the 'extern' keyword in a function declaration in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to pass an array to a function in C++?
Correct Answer: Option C — By passing the array name and size as parameters
Detailed Academic Explanation:
By passing the array name and size as parameters is the correct answer to “What is the correct way to pass an array to a function in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'static' keyword in a C++ function?
Correct Answer: Option D — Retains the variable's value between function calls
Detailed Academic Explanation:
Retains the variable's value between function calls is the correct answer to “What is the purpose of the 'static' keyword in a C++ function”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'void' keyword represent in the function declaration in C++?
Correct Answer: Option A — Indicates that the function does not return any value
Detailed Academic Explanation:
Indicates that the function does not return any value is the correct answer to “What does the 'void' keyword represent in the function declaration in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is true about inline functions in C++?
Correct Answer: Option D — The compiler replaces the function call with the function code wherever it is called
Detailed Academic Explanation:
The compiler replaces the function call with the function code wherever it is called is the correct answer to “Which of the following is true about inline functions in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int add(int a, int b) { return a + b; } int sum = add(3, 5); cout << sum; in C++?
Correct Answer: Option C — 8
Detailed Academic Explanation:
8 is the correct answer to “What is the output of the following code: int add(int a, int b) { return a + b; } int sum = add(3, 5); cout << sum; in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C++, what is the significance of the function return type 'auto'?
Correct Answer: Option B — The compiler automatically deduces the return type based on the return statement
Detailed Academic Explanation:
The compiler automatically deduces the return type based on the return statement is the correct answer to “In C++, what is the significance of the function return type 'auto'”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'friend' keyword in a C++ function declaration?
Correct Answer: Option C — It grants access to private and protected members of a class to the function
Detailed Academic Explanation:
It grants access to private and protected members of a class to the function is the correct answer to “What is the purpose of the 'friend' keyword in a C++ function declaration”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for declaring a function that takes a variable number of arguments in C++?
Correct Answer: Option D — returnType functionName(...)
Detailed Academic Explanation:
returnType functionName(...) is the correct answer to “What is the syntax for declaring a function that takes a variable number of arguments in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int x = 5; cout << "Before: " << x; changeValue(x); cout << "After: " << x; in C++?
Correct Answer: Option A — Before: 5 After: 5
Detailed Academic Explanation:
Before: 5 After: 5 is the correct answer to “What is the output of the following code: int x = 5; cout << "Before: " << x; changeValue(x); cout << "After: " << x; in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax for defining a function template in C++?
template returnType functionName(T parameter) { body; } is the correct answer to “What is the correct syntax for defining a function template in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'const' keyword in a function parameter list in C++?
Correct Answer: Option C — Indicates that the parameter value cannot be changed within the function
Detailed Academic Explanation:
Indicates that the parameter value cannot be changed within the function is the correct answer to “What is the purpose of the 'const' keyword in a function parameter list in C++”. This question is standard in competitive examination syllabi for Functions And Procedures In C Plus Plus.
💡Key Conceptual Anchor:Functions And Procedures In C Plus Plus
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.