Skip to main content

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
Question 1 of 40
★ FPSC ★ PPSC

In C++, what is a lambda function?

Question 2 of 40
★ FPSC ★ PPSC

What is the purpose of the 'decltype' keyword in C++?

Question 3 of 40
★ FPSC ★ PPSC

What is the correct way to declare a function that takes a pointer as an argument in C++?

Question 4 of 40
★ FPSC ★ PPSC

What will be the output of the following code: void display() { cout << "Hello"; } int main() { display(); return 0; } in C++?

Question 5 of 40
★ 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; }

Question 6 of 40
★ FPSC ★ PPSC

If we start our function call with default arguments means, what will be proceeding arguments?

Question 7 of 40
★ FPSC ★ PPSC

Which of the following is the default return value of functions in C++?

Question 8 of 40
★ FPSC ★ PPSC

What is an inline function?

Question 9 of 40
★ 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; }

Question 10 of 40
★ FPSC ★ PPSC

Identify the correct statement.

Question 11 of 40
★ FPSC ★ PPSC

What is the scope of the variable declared in the user defined function?

Question 12 of 40
★ FPSC ★ PPSC

If an argument from the parameter list of a function is defined constant then . . . . . . . .

Question 13 of 40
★ 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; }

Question 14 of 40
★ 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; }

Question 15 of 40
★ FPSC ★ PPSC

which of the following can be passed in function pointers?

Question 16 of 40
★ FPSC ★ PPSC

Where should default parameters appear in a function prototype?

Question 17 of 40
★ 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; }

Question 18 of 40
★ FPSC ★ PPSC

Which is more effective while calling the functions?

Question 19 of 40
★ FPSC ★ PPSC

What is similar to the interface in c++?

Question 20 of 40
★ 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; }

Question 21 of 40
★ 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; }

Question 22 of 40
★ FPSC ★ PPSC

Pick the incorrect statement for namespaces in C++.

Question 23 of 40
★ 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; }

Question 24 of 40
★ FPSC ★ PPSC

What will happen when the exception is not caught in the program?

Question 25 of 40
★ FPSC ★ PPSC

What should be passed in parameters when function does not require any parameters?

Question 26 of 40
★ FPSC ★ PPSC

How many types do functions fall depends on modularization?

Question 27 of 40
★ 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); }

Question 28 of 40
★ FPSC ★ PPSC

Which keyword is used to access the variable in the namespace?

Question 29 of 40
★ FPSC ★ PPSC

Where can the default parameter be placed by the user?

Question 30 of 40
★ FPSC ★ PPSC

What will happen while using pass by reference?

Question 31 of 40
★ 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; }

Question 32 of 40
★ FPSC ★ PPSC

Which operator is used to signify the namespace?

Question 33 of 40
★ FPSC ★ PPSC

which keyword is used to define the macros in c++?

Question 34 of 40
★ 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; }

Question 35 of 40
★ 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; }

Question 36 of 40
★ FPSC ★ PPSC

In which of the following we cannot overload the function?

Question 37 of 40
★ 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); }

Question 38 of 40
★ FPSC ★ PPSC

Which keyword is used to check exception in the block of code?

Question 39 of 40
★ 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

Question 40 of 40
★ FPSC ★ PPSC

Which operator is used for accessing a member of namespace?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →