C Plus Plus Miscellaneous — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on C Plus Plus Miscellaneous — 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
How many kinds of parameters are there in C++?
Correct Answer: Option C — 3
Detailed Academic Explanation:
3 is the correct answer to “How many kinds of parameters are there in C++”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <functional> #include <numeric> using namespace std; int myfunction (int x, int y) { return x + 2 * y; } struct myclass { int operator()(int x, int y) { return x + 3 * y; } } myobject; int main () { int init = 100; int numbers[] = {10, 20, 30}; cout << accumulate(numbers, numbers + 3, init); cout << endl; }
Correct Answer: Option C — 160
Detailed Academic Explanation:
160 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <functional> #include <numeric> using namespace std; int myfunction (int x, int y) { return x + 2 * y; } struct myclass { int operator()(int x, int y) { return x + 3 * y; } } myobject; int main () { int init = 100; int numbers[] = {10, 20, 30}; cout << accumulate(numbers, numbers + 3, init); cout << endl; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is used to get the input during runtime?
Correct Answer: Option B — cin
Detailed Academic Explanation:
cin is the correct answer to “Which is used to get the input during runtime”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is meant by pure virtual function?
Correct Answer: Option A — Function which does not have definition of its own
Detailed Academic Explanation:
Function which does not have definition of its own is the correct answer to “What is meant by pure virtual function”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class poly { protected: int width, height; public: void set_values(int a, int b) { width = a; height = b; } }; class Coutput { public: void output(int i); }; void Coutput::output(int i) { cout << i; } class rect:public poly, public Coutput { public: int area() { return(width * height); } }; class tri:public poly, public Coutput { public: int area() { return(width * height / 2); } }; int main() { rect rect; tri trgl; rect.set_values(3, 4); trgl.set_values(4, 5); rect.output(rect.area()); trgl.output(trgl.area()); return 0; }
Correct Answer: Option B — 1210
Detailed Academic Explanation:
1210 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class poly { protected: int width, height; public: void set_values(int a, int b) { width = a; height = b; } }; class Coutput { public: void output(int i); }; void Coutput::output(int i) { cout << i; } class rect:public poly, public Coutput { public: int area() { return(width * height); } }; class tri:public poly, public Coutput { public: int area() { return(width * height / 2); } }; int main() { rect rect; tri trgl; rect.set_values(3, 4); trgl.set_values(4, 5); rect.output(rect.area()); trgl.output(trgl.area()); return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many types of sequence operations are provided by the C++ algorithm STL?
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “How many types of sequence operations are provided by the C++ algorithm STL”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <memory> #include <string> using namespace std; int main () { string numbers[] = {"steve", "jobs"}; pair <string*, ptrdiff_t> result = get_temporary_buffer<string>(2); if (result.second>0) { uninitialized_copy ( numbers, numbers + result.second, result.first ); for (int i = 0; i < result.second; i++) cout << result.first[i] << " "; return_temporary_buffer(result.first); } return 0; }
Correct Answer: Option D — steve jobs
Detailed Academic Explanation:
steve jobs is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <memory> #include <string> using namespace std; int main () { string numbers[] = {"steve", "jobs"}; pair <string*, ptrdiff_t> result = get_temporary_buffer<string>(2); if (result.second>0) { uninitialized_copy ( numbers, numbers + result.second, result.first ); for (int i = 0; i < result.second; i++) cout << result.first[i] << " "; return_temporary_buffer(result.first); } return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What kind of iteration does forward_list provide in C++?
Correct Answer: Option A — Uni-directional
Detailed Academic Explanation:
Uni-directional is the correct answer to “What kind of iteration does forward_list provide in C++”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following header file is needed to use vectors in your program?
Correct Answer: Option B — <vector>
Detailed Academic Explanation:
<vector> is the correct answer to “Which of the following header file is needed to use vectors in your program”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <string> #include <iostream> using namespace std; void string_permutation( string& orig, string& perm ) { if (orig.empty()) { cout<<perm<<endl; return; } for (int i = 0; i < orig.size(); ++i) { string orig2 = orig; orig2.erase(i, 1); string perm2 = perm; perm2 += orig.at(i); string_permutation(orig2, perm2); } } int main() { string orig = "ter"; string perm; string_permutation(orig, perm); return 0; }
Correct Answer: Option D — returns all the combination of ter
Detailed Academic Explanation:
returns all the combination of ter is the correct answer to “What will be the output of the following C++ code? #include <string> #include <iostream> using namespace std; void string_permutation( string& orig, string& perm ) { if (orig.empty()) { cout<<perm<<endl; return; } for (int i = 0; i < orig.size(); ++i) { string orig2 = orig; orig2.erase(i, 1); string perm2 = perm; perm2 += orig.at(i); string_permutation(orig2, perm2); } } int main() { string orig = "ter"; string perm; string_permutation(orig, perm); return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What type of class template is list?
Correct Answer: Option B — Node-based
Detailed Academic Explanation:
Node-based is the correct answer to “What type of class template is list”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Pick out the correct statement about vector.
Correct Answer: Option A — vector<int> values (5)
Detailed Academic Explanation:
vector<int> values (5) is the correct answer to “Pick out the correct statement about vector.”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do define the user-defined exceptions?
Correct Answer: Option A — inheriting and overriding exception class functionality
Detailed Academic Explanation:
inheriting and overriding exception class functionality is the correct answer to “How do define the user-defined exceptions”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main () { vector<int> first; first.assign (7,100); vector<int>::iterator it; it=first.begin()+1; int myints[] = {1776,7,4}; cout << int (first.size()) << '\n'; return 0; }
Correct Answer: Option D — 7
Detailed Academic Explanation:
7 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main () { vector<int> first; first.assign (7,100); vector<int>::iterator it; it=first.begin()+1; int myints[] = {1776,7,4}; cout << int (first.size()) << '\n'; return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <Valarray> using namespace std; int main() { Valarray<int> varr = { 1, 2, 3, 4, 5 }; for (int &x: varr) cout << x << " "; cout<<endl; varr = varr.shift(2); for (int &x: varr) cout << x << " "; return 0; }
Correct Answer: Option A — 1 2 3 4 5 3 4 5 0 0
Detailed Academic Explanation:
1 2 3 4 5 3 4 5 0 0 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <Valarray> using namespace std; int main() { Valarray<int> varr = { 1, 2, 3, 4, 5 }; for (int &x: varr) cout << x << " "; cout<<endl; varr = varr.shift(2); for (int &x: varr) cout << x << " "; return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function will be called when we have an uncaught exception?
Correct Answer: Option C — terminate
Detailed Academic Explanation:
terminate is the correct answer to “What function will be called when we have an uncaught exception”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <vector> #include <forward_list> using namespace std; int main() { forward_list<int> fl1 = {1,2,3,4,5}; for (int&c : fl1) cout << c << " "; cout<<endl; fl1.remove_if([](int x){ return x > 3;}); for (int&c : fl1) cout << c << " "; cout<<endl; return 0; }
Correct Answer: Option C — 1 2 3 4 5 1 2 3
Detailed Academic Explanation:
1 2 3 4 5 1 2 3 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <vector> #include <forward_list> using namespace std; int main() { forward_list<int> fl1 = {1,2,3,4,5}; for (int&c : fl1) cout << c << " "; cout<<endl; fl1.remove_if([](int x){ return x > 3;}); for (int&c : fl1) cout << c << " "; cout<<endl; return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <valarray> using namespace std; int main() { valarray<int> varr = { 10, 2, 20, 1, 30 }; cout<<"Sum of array: "<<varr.sum(); return 0; }
Correct Answer: Option D — Sum of array: 63
Detailed Academic Explanation:
Sum of array: 63 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <valarray> using namespace std; int main() { valarray<int> varr = { 10, 2, 20, 1, 30 }; cout<<"Sum of array: "<<varr.sum(); return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class Base { public: Base ( ) { cout << "1" << endl; } ~Base ( ) { cout << "2" << endl; } }; class Derived : public Base { public: Derived ( ) { cout << "3" << endl; } ~Derived ( ) { cout << "4" << endl; } }; int main( ) { Derived x; }
Correct Answer: Option D — 1342
Detailed Academic Explanation:
1342 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class Base { public: Base ( ) { cout << "1" << endl; } ~Base ( ) { cout << "2" << endl; } }; class Derived : public Base { public: Derived ( ) { cout << "3" << endl; } ~Derived ( ) { cout << "4" << endl; } }; int main( ) { Derived x; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <bitset> using namespace std; int main() { bitset<8> b1(95); bitset<8> b2 = b1 << 3; cout<<b2; }
Correct Answer: Option B — 11111000
Detailed Academic Explanation:
11111000 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <bitset> using namespace std; int main() { bitset<8> b1(95); bitset<8> b2 = b1 << 3; cout<<b2; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the main feature of locale in C++?
Correct Answer: Option B — Portability
Detailed Academic Explanation:
Portability is the correct answer to “What is the main feature of locale in C++”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Elements in STL heap are removed in . . . . . . . .
Correct Answer: Option A — decreasing order
Detailed Academic Explanation:
decreasing order is the correct answer to “Elements in STL heap are removed in . . . . . . . .”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { vector<int> myvector; for (int i = 1; i < 5; ++i) myvector.push_back(i); rotate(myvector.begin(), myvector.begin() + 3, myvector.end( )); for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it) cout << ' ' << *it; return 0; }
Correct Answer: Option D — 4 1 2 3
Detailed Academic Explanation:
4 1 2 3 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { vector<int> myvector; for (int i = 1; i < 5; ++i) myvector.push_back(i); rotate(myvector.begin(), myvector.begin() + 3, myvector.end( )); for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it) cout << ' ' << *it; return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are command line arguments?
Correct Answer: Option A — Arguments passed to main() function
Detailed Academic Explanation:
Arguments passed to main() function is the correct answer to “What are command line arguments”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many parameters are there in getline function?
Correct Answer: Option C — 2 or 3
Detailed Academic Explanation:
2 or 3 is the correct answer to “How many parameters are there in getline function”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following relationships is uni-directional?
Correct Answer: Option D — Both Aggregation and Composition
Detailed Academic Explanation:
Both Aggregation and Composition is the correct answer to “Which of the following relationships is uni-directional”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 10; if (a < 15) { time: cout << a; goto time; } break; 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 main() { int a = 10; if (a < 15) { time: cout << a; goto time; } break; return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is used to create a pure virtual function?
Correct Answer: Option B — =0
Detailed Academic Explanation:
=0 is the correct answer to “Which is used to create a pure virtual function”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { int num = 3; string str_bad = "wrong number used"; try { if ( num == 1 ) { throw 5; } if ( num == 2 ) { throw 1.1f; } if ( num != 1 || num != 2 ) { throw str_bad; } } catch (int a) { cout << "Exception is: " << a << endl; } catch (float b) { cout << "Exception is: " << b << endl; } catch (...) { cout << str_bad << endl; } return 0; }
Correct Answer: Option C — Wrong number used
Detailed Academic Explanation:
Wrong number used is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { int num = 3; string str_bad = "wrong number used"; try { if ( num == 1 ) { throw 5; } if ( num == 2 ) { throw 1.1f; } if ( num != 1 || num != 2 ) { throw str_bad; } } catch (int a) { cout << "Exception is: " << a << endl; } catch (float b) { cout << "Exception is: " << b << endl; } catch (...) { cout << str_bad << endl; } return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following function is used to insert an element at the end of a vector?
Correct Answer: Option A — push_back()
Detailed Academic Explanation:
push_back() is the correct answer to “Which of the following function is used to insert an element at the end of a vector”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are the tuples in C++?
Correct Answer: Option A — Objects that can hold more than one element of different types
Detailed Academic Explanation:
Objects that can hold more than one element of different types is the correct answer to “What are the tuples in C++”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many ways of reusing are there in the class hierarchy?
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “How many ways of reusing are there in the class hierarchy”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which header file is used for the numeric limits in C++?
Correct Answer: Option B — <limits>
Detailed Academic Explanation:
<limits> is the correct answer to “Which header file is used for the numeric limits in C++”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <tuple> using namespace std; int main() { tuple <int, char, string> tp1; tuple <int, char, string> tp2; tp1 = make_tuple(6, 'a', "Hello"); tp2 = make_tuple(9, 'z', "World"); cout<<"("<<get<0>(tp1)<<", "<<get<1>(tp1)<<", "<<get<2>(tp1)<<")"<<endl; cout<<"("<<get<0>(tp2)<<", "<<get<1>(tp2)<<", "<<get<2>(tp2)<<")"<<endl; tp1.swap(tp2); cout<<"("<<get<0>(tp1)<<", "<<get<1>(tp1)<<", "<<get<2>(tp1)<<")"<<endl; cout<<"("<<get<0>(tp2)<<", "<<get<1>(tp2)<<", "<<get<2>(tp2)<<")"<<endl; return 0; }
Correct Answer: Option A — (6, a, Hello) (9, z, World) (9, z, World) (6, a, Hello)
Detailed Academic Explanation:
(6, a, Hello) (9, z, World) (9, z, World) (6, a, Hello) is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <tuple> using namespace std; int main() { tuple <int, char, string> tp1; tuple <int, char, string> tp2; tp1 = make_tuple(6, 'a', "Hello"); tp2 = make_tuple(9, 'z', "World"); cout<<"("<<get<0>(tp1)<<", "<<get<1>(tp1)<<", "<<get<2>(tp1)<<")"<<endl; cout<<"("<<get<0>(tp2)<<", "<<get<1>(tp2)<<", "<<get<2>(tp2)<<")"<<endl; tp1.swap(tp2); cout<<"("<<get<0>(tp1)<<", "<<get<1>(tp1)<<", "<<get<2>(tp1)<<")"<<endl; cout<<"("<<get<0>(tp2)<<", "<<get<1>(tp2)<<", "<<get<2>(tp2)<<")"<<endl; return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <vector> #include <algorithm> using namespace std; void show(const vector<int>& vi) { for (size_t i = 0; i < vi.size(); ++i) cout << vi[i]; cout << endl; } int main() { vector<int> vi; vi.push_back(3); vi.push_back(5); vi.push_back(5); sort(vi.begin(), vi.end()); show(vi); while(next_permutation(vi.begin(), vi.end())) show(vi); return 0; }
Correct Answer: Option D — 355 535 553
Detailed Academic Explanation:
355 535 553 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <vector> #include <algorithm> using namespace std; void show(const vector<int>& vi) { for (size_t i = 0; i < vi.size(); ++i) cout << vi[i]; cout << endl; } int main() { vector<int> vi; vi.push_back(3); vi.push_back(5); vi.push_back(5); sort(vi.begin(), vi.end()); show(vi); while(next_permutation(vi.begin(), vi.end())) show(vi); return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In how many different ways any-container can be constructed?
Correct Answer: Option C — 3
Detailed Academic Explanation:
3 is the correct answer to “In how many different ways any-container can be constructed”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does this template function indicates? ================== template<class T, class U> U func(T a, U b) { cout<<a<<"\t"<<b; } ==================
Correct Answer: Option A — A function taking a single generic parameter and returning a generic type which may be different from argument type
Detailed Academic Explanation:
A function taking a single generic parameter and returning a generic type which may be different from argument type is the correct answer to “What does this template function indicates? ================== template<class T, class U> U func(T a, U b) { cout<<a<<"\t"<<b; } ==================”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { vector<int> v = {4,2,10,5,1,8}; sort(v.begin(), v.end()); if (binary_search(v.begin(), v.end(), 4)) cout << "found.\n"; else cout << "not found.\n"; return 0; }
Correct Answer: Option A — found.
Detailed Academic Explanation:
found. is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { vector<int> v = {4,2,10,5,1,8}; sort(v.begin(), v.end()); if (binary_search(v.begin(), v.end(), 4)) cout << "found.\n"; else cout << "not found.\n"; return 0; }”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Identify the correct statement about throw(type).
Correct Answer: Option B — A function can throw an exception of certain type only
Detailed Academic Explanation:
A function can throw an exception of certain type only is the correct answer to “Identify the correct statement about throw(type).”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator is used as catch-all handler?
Correct Answer: Option A — ellipses operator
Detailed Academic Explanation:
ellipses operator is the correct answer to “Which operator is used as catch-all handler”. This question is standard in competitive examination syllabi for C Plus Plus Miscellaneous.
💡Key Conceptual Anchor:C Plus Plus Miscellaneous
✓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.