Skip to main content

Arrays And Strings In C Plus Plus — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Arrays And Strings In C Plus Plus — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
32
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
39 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
32

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/32 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 32
★ FPSC ★ PPSC

How do you access the element at the second row and third column of a two-dimensional array named 'matrix' in C++?

Question 2 of 32
★ FPSC ★ PPSC

Which of the following is true regarding the declaration of a string in C++ using the char array?

Question 3 of 32
★ FPSC ★ PPSC

Which is an instantiation of the basic_string class template?

Question 4 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str="Steve Jobs founded the apple"; string str2 = str.substr (6, 4); unsigned pos = str.find("the"); string str3 = str.substr (pos); cout << str2 << ' ' << str3 << '\n'; return 0; }

Question 5 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include<iostream> using namespace std; int main() { int a = 5, b = 10, c = 15; int arr[3] = {&a, &b, &c}; cout << *arr[*arr[1] - 8]; return 0; }

Question 6 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("Steve jobs"); cout << str.length(); return 0; }

Question 7 of 32
★ FPSC ★ PPSC

What will happen if a string is empty?

Question 8 of 32
★ FPSC ★ PPSC

How many parameters can a resize method take?

Question 9 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include <iostream> using namespace std; int main() { int array[] = {10, 20, 30}; cout << -2[array]; return 0; }

Question 10 of 32
★ FPSC ★ PPSC

What is the difference between unsigned int length() and unsigned int size()?

Question 11 of 32
★ FPSC ★ PPSC

How does the strings are stored in the memory?

Question 12 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include<iostream> using namespace std; int array1[] = {1200, 200, 2300, 1230, 1543}; int array2[] = {12, 14, 16, 18, 20}; int temp, result = 0; int main() { for (temp = 0; temp < 5; temp++) { result += array1[temp]; } for (temp = 0; temp < 4; temp++) { result += array2[temp]; } cout << result; return 0; }

Question 13 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("Steve jobs"); cout << str.capacity() << "\n"; return 0; }

Question 14 of 32
★ FPSC ★ PPSC

How many maximum number of parameters does a string constructor can take?

Question 15 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str; string str2="Steve jobs"; string str3="He founded apple"; str.append(str2); str.append(str3, 6, 3); str.append(str3.begin() + 6, str3.end()); str.append(5,0x2e); cout << str << '\n'; return 0; }

Question 16 of 32
★ FPSC ★ PPSC

Which of the following accesses the seventh element stored in array?

Question 17 of 32
★ FPSC ★ PPSC

What is the correct definition of an array?

Question 18 of 32
★ FPSC ★ PPSC

Which of the following gives the memory address of the first element in array?

Question 19 of 32
★ FPSC ★ PPSC

Which character is used to terminate the string?

Question 20 of 32
★ FPSC ★ PPSC

Where are the strings stored?

Question 21 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("I like to code in C"); unsigned sz = str.size(); str.resize (sz + 2, '+'); str.resize (14); cout << str << '\n'; return 0; }

Question 22 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <cstring> #include <string> using namespace std; int main () { string str ("Steve jobs"); char * cstr = new char [str.length() + 1]; strcpy (cstr, str.c_str()); char * p = strtok (cstr," "); while (p != 0) { cout << p << '\n'; p = strtok(NULL," "); } delete[] cstr; return 0; }

Question 23 of 32
★ FPSC ★ PPSC

Which constant member functions does not modify the string?

Question 24 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include <iostream> using namespace std; int main() { char str[5] = "ABC"; cout << str[3]; cout << str; return 0; }

Question 25 of 32
★ FPSC ★ PPSC

What is the index number of the last element of an array with 9 elements?

Question 26 of 32
★ FPSC ★ PPSC

Which header file is used to manipulate the string?

Question 27 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("Test string"); for ( string :: iterator it = str.begin(); it != 5; ++it) cout << *it; return 0; }

Question 28 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("Steve jobs founded the apple"); string str2 ("apple"); unsigned found = str.find(str2); if (found != string :: npos) cout << found << '\n'; return 0; }

Question 29 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string name ("Jobs"); string family ("Steve"); name += " Apple "; name += family; name += '\n'; cout << name; return 0; }

Question 30 of 32
★ FPSC ★ PPSC

Which of the following correctly declares an array?

Question 31 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <stdio.h> #include<iostream> using namespace std; int main () { int array[] = {0, 2, 4, 6, 7, 5, 3}; int n, result = 0; for (n = 0; n < 8; n++) { result += array[n]; } cout << result; return 0; }

Question 32 of 32
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("Steve jobs"); unsigned long int found = str.find_first_of("aeiou"); while (found != string :: npos) { str[found] = '*'; found = str.find_first_of("aeiou", found + 1); } cout << str << '\n'; return 0; }

✓ 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 →