Functions And Procedures In C Plus Plus — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Functions And Procedures In C Plus Plus — Part 2 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
In C++, what is a lambda function?
Correct Answer: Option B — An anonymous function that can be used as an argument to other functions
Detailed Academic Explanation:
An anonymous function that can be used as an argument to other functions is the correct answer to “In C++, what is a lambda 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 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'decltype' keyword in C++?
Correct Answer: Option A — Determines the type of an expression or variable
Detailed Academic Explanation:
Determines the type of an expression or variable is the correct answer to “What is the purpose of the 'decltype' keyword 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 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to declare a function that takes a pointer as an argument in C++?
Correct Answer: Option D — returnType functionName(type* parameter)
Detailed Academic Explanation:
returnType functionName(type* parameter) is the correct answer to “What is the correct way to declare a function that takes a pointer as an argument 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 will be the output of the following code: void display() { cout << "Hello"; } int main() { display(); return 0; } in C++?
Correct Answer: Option C — Hello
Detailed Academic Explanation:
Hello is the correct answer to “What will be the output of the following code: void display() { cout << "Hello"; } int main() { display(); return 0; } 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
What will be the output of the following C++ code? #include <iostream> using namespace std; int func (int a, int b) { cout << a; cout << b; return 0; } int main(void) { int(*ptr)(char, int); ptr = func; func(2, 3); ptr(2, 3); return 0; }
Correct Answer: Option D — compile time error
Detailed Academic Explanation:
compile time error is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int func (int a, int b) { cout << a; cout << b; return 0; } int main(void) { int(*ptr)(char, int); ptr = func; func(2, 3); ptr(2, 3); return 0; }”. 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
If we start our function call with default arguments means, what will be proceeding arguments?
Correct Answer: Option C — default arguments
Detailed Academic Explanation:
default arguments is the correct answer to “If we start our function call with default arguments means, what will be proceeding arguments”. 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
Which of the following is the default return value of functions in C++?
Correct Answer: Option A — int
Detailed Academic Explanation:
int is the correct answer to “Which of the following is the default return value of 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 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is an inline function?
Correct Answer: Option A — A function that is expanded at each call during execution
Detailed Academic Explanation:
A function that is expanded at each call during execution is the correct answer to “What is an inline 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 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? include <iostream> using namespace std; long factorial (long a) { if (a > 1) return (a * factorial (a + 1)); else return (1); } int main () { long num = 3; cout << num << "! = " << factorial ( num ); return 0; }
Correct Answer: Option C — segmentation fault
Detailed Academic Explanation:
segmentation fault is the correct answer to “What will be the output of the following C++ code? include <iostream> using namespace std; long factorial (long a) { if (a > 1) return (a * factorial (a + 1)); else return (1); } int main () { long num = 3; cout << num << "! = " << factorial ( num ); return 0; }”. 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
Identify the correct statement.
Correct Answer: Option A — Namespace is used to group class, objects and functions
Detailed Academic Explanation:
Namespace is used to group class, objects and functions is the correct answer to “Identify the correct statement.”. 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 scope of the variable declared in the user defined function?
Correct Answer: Option B — only inside the {} block
Detailed Academic Explanation:
only inside the {} block is the correct answer to “What is the scope of the variable declared in the user defined 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 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If an argument from the parameter list of a function is defined constant then . . . . . . . .
Correct Answer: Option B — It cannot be modified inside the function
Detailed Academic Explanation:
It cannot be modified inside the function is the correct answer to “If an argument from the parameter list of a function is defined constant then . . . . . . . .”. 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 will be the output of the following C++ code? #include <iostream> using namespace std; void Funct(); int main() { try { Funct(); } catch(double) { cerr << "caught a double type..." << endl; } return 0; } void Funct() { throw 3; }
Correct Answer: Option C — abnormal program termination
Detailed Academic Explanation:
abnormal program termination is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; void Funct(); int main() { try { Funct(); } catch(double) { cerr << "caught a double type..." << endl; } return 0; } void Funct() { throw 3; }”. 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 will be the output of the following C++ code? #include <iostream> using namespace std; void Sum(int a, int b, int & c) { a = b + c; b = a + c; c = a + b; } int main() { int x = 2, y =3; Sum(x, y, y); cout << x << " " << y; return 0; }
Correct Answer: Option C — 2 15
Detailed Academic Explanation:
2 15 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; void Sum(int a, int b, int & c) { a = b + c; b = a + c; c = a + b; } int main() { int x = 2, y =3; Sum(x, y, y); cout << x << " " << y; return 0; }”. 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 can be passed in function pointers?
Correct Answer: Option C — functions
Detailed Academic Explanation:
functions is the correct answer to “which of the following can be passed in function pointers”. 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
Where should default parameters appear in a function prototype?
Correct Answer: Option A — To the rightmost side of the parameter list
Detailed Academic Explanation:
To the rightmost side of the parameter list is the correct answer to “Where should default parameters appear in a function prototype”. 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
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; namespace A{ int var = 10; } namespace B{ int cout = 5; } int main() { using namespace B; cout<<A::var; }
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; namespace A{ int var = 10; } namespace B{ int cout = 5; } int main() { using namespace B; cout<<A::var; }”. 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
Which is more effective while calling the functions?
Correct Answer: Option B — call by reference
Detailed Academic Explanation:
call by reference is the correct answer to “Which is more effective while calling the 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 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is similar to the interface in c++?
Correct Answer: Option C — pure abstract class
Detailed Academic Explanation:
pure abstract class is the correct answer to “What is similar to the interface 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 will be the output of the following C++ code? #include <iostream> using namespace std; void print(int i) { cout << i; } void print(double f) { cout << f; } int main(void) { print(5); print(500.263); return 0; }
Correct Answer: Option A — 5500.263
Detailed Academic Explanation:
5500.263 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; void print(int i) { cout << i; } void print(double f) { cout << f; } int main(void) { print(5); print(500.263); return 0; }”. 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
What will be the output of the following C++ code? #include <iostream> using namespace std; #define SquareOf(x) x * x int main() { int x; cout << SquareOf(x + 4); return 0; }
Correct Answer: Option D — 75386824
Detailed Academic Explanation:
75386824 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; #define SquareOf(x) x * x int main() { int x; cout << SquareOf(x + 4); return 0; }”. 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
Pick the incorrect statement for namespaces in C++.
Correct Answer: Option C — Namespace has access specifiers like private or public
Detailed Academic Explanation:
Namespace has access specifiers like private or public is the correct answer to “Pick the incorrect statement for namespaces 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 will be the output of the following C++ code? #include <iostream> #include <stdarg.h> using namespace std; int add (int num, ...) { int sum = 0; va_list args; va_start (args,num); for (int i = 0; i < num; i++) { int num = va_arg (args,int); sum += num; } va_end (args); return sum; } int main (void) { int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7); cout << "The result is " << total; return 0; }
Correct Answer: Option A — 32
Detailed Academic Explanation:
32 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <stdarg.h> using namespace std; int add (int num, ...) { int sum = 0; va_list args; va_start (args,num); for (int i = 0; i < num; i++) { int num = va_arg (args,int); sum += num; } va_end (args); return sum; } int main (void) { int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7); cout << "The result is " << total; return 0; }”. 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 will happen when the exception is not caught in the program?
Correct Answer: Option A — error
Detailed Academic Explanation:
error is the correct answer to “What will happen when the exception is not caught in the program”. 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
What should be passed in parameters when function does not require any parameters?
Correct Answer: Option B — blank space
Detailed Academic Explanation:
blank space is the correct answer to “What should be passed in parameters when function does not require any parameters”. 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
How many types do functions fall depends on modularization?
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “How many types do functions fall depends on modularization”. 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 will be the output of the following C++ code? #include <iostream> #include <stdarg.h> using namespace std; void dumplist(int, ...); int main() { dumplist(2, 4, 8); dumplist(3, 6, 9, 7); return 0; } void dumplist(int n, ...) { va_list p; int i; va_start(p, n); while (n-->0) { i = va_arg(p, int); cout << i; } va_end(p); }
Correct Answer: Option B — 48697
Detailed Academic Explanation:
48697 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <stdarg.h> using namespace std; void dumplist(int, ...); int main() { dumplist(2, 4, 8); dumplist(3, 6, 9, 7); return 0; } void dumplist(int n, ...) { va_list p; int i; va_start(p, n); while (n-->0) { i = va_arg(p, int); cout << i; } va_end(p); }”. 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
Which keyword is used to access the variable in the namespace?
Correct Answer: Option A — using
Detailed Academic Explanation:
using is the correct answer to “Which keyword is used to access the variable in the namespace”. 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
Where can the default parameter be placed by the user?
Correct Answer: Option B — rightmost
Detailed Academic Explanation:
rightmost is the correct answer to “Where can the default parameter be placed by the user”. 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 will happen while using pass by reference?
Correct Answer: Option B — The location of variable in memory is passed to the function so that it can use the same memory area for its processing
Detailed Academic Explanation:
The location of variable in memory is passed to the function so that it can use the same memory area for its processing is the correct answer to “What will happen while using pass by reference”. 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 will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; namespace { int var = 10; } int main() { cout<<var; }
Correct Answer: Option A — 10
Detailed Academic Explanation:
10 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; namespace { int var = 10; } int main() { cout<<var; }”. 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
Which operator is used to signify the namespace?
Correct Answer: Option C — scope operator
Detailed Academic Explanation:
scope operator is the correct answer to “Which operator is used to signify the namespace”. 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 keyword is used to define the macros in c++?
Correct Answer: Option C — #define
Detailed Academic Explanation:
#define is the correct answer to “which keyword is used to define the macros 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 will be the output of the following C++ code? #include <iostream> using namespace std; int operate (int a, int b) { return (a * b); } float operate (float a, float b) { return (a / b); } int main() { int x = 5, y = 2; float n = 5.0, m = 2.0; cout << operate(x, y) <<"\t"; cout << operate (n, m); return 0; }
Correct Answer: Option D — 10 2.5
Detailed Academic Explanation:
10 2.5 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int operate (int a, int b) { return (a * b); } float operate (float a, float b) { return (a / b); } int main() { int x = 5, y = 2; float n = 5.0, m = 2.0; cout << operate(x, y) <<"\t"; cout << operate (n, m); return 0; }”. 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
What will be the output of the following C++ code? #include <iostream> using namespace std; #define PR(id) cout << "The value of " #id " is "<<id int main() { int i = 10; PR(i); return 0; }
Correct Answer: Option A — 10
Detailed Academic Explanation:
10 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; #define PR(id) cout << "The value of " #id " is "<<id int main() { int i = 10; PR(i); return 0; }”. 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
In which of the following we cannot overload the function?
Correct Answer: Option A — return function
Detailed Academic Explanation:
return function is the correct answer to “In which of the following we cannot overload the 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 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int fun(int=0, int = 0); int main() { cout << fun(5); return 0; } int fun(int x, int y) { return (x+y); }
Correct Answer: Option D — 5
Detailed Academic Explanation:
5 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int fun(int=0, int = 0); int main() { cout << fun(5); return 0; } int fun(int x, int y) { return (x+y); }”. 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
Which keyword is used to check exception in the block of code?
Correct Answer: Option C — try
Detailed Academic Explanation:
try is the correct answer to “Which keyword is used to check exception in the block of code”. 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
In which of the following cases inline functions may not word? i. If the function has static variables. ii. If the function has global and register variables. iii. If the function contains loops iv. If the function is recursive
Correct Answer: Option D — i, iii, iv
Detailed Academic Explanation:
i, iii, iv is the correct answer to “In which of the following cases inline functions may not word? i. If the function has static variables. ii. If the function has global and register variables. iii. If the function contains loops iv. If the function is recursive”. 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
Which operator is used for accessing a member of namespace?
Correct Answer: Option B — ::
Detailed Academic Explanation:
:: is the correct answer to “Which operator is used for accessing a member of namespace”. 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.