Skip to main content

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

Practice high-yield Programming & Software Development MCQs on Arrays And Strings 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
Question 1 of 40
★ FPSC ★ PPSC

What is the correct way to declare a one-dimensional array in C++?

Question 2 of 40
★ FPSC ★ PPSC

How do you access the third element of an array named 'arr' in C++?

Question 3 of 40
★ FPSC ★ PPSC

What is the size of the following array declaration in C++: char str[10];?

Question 4 of 40
★ FPSC ★ PPSC

What is the purpose of the 'strlen()' function in C++?

Question 5 of 40
★ FPSC ★ PPSC

How do you initialize all elements of an integer array named 'arr' to zero in C++?

Question 6 of 40
★ FPSC ★ PPSC

What is the correct syntax for declaring a two-dimensional array in C++?

Question 7 of 40
★ FPSC ★ PPSC

Which of the following statements is true about C-style strings in C++?

Question 8 of 40
★ FPSC ★ PPSC

What is the output of the following code: char str[] = "Hello"; cout << str[5]; in C++?

Question 9 of 40
★ FPSC ★ PPSC

How do you determine the length of a C-style string in C++?

Question 10 of 40
★ FPSC ★ PPSC

What is the correct way to pass an array as an argument to a function in C++?

Question 11 of 40
★ FPSC ★ PPSC

What does the 'strcpy()' function do in C++?

Question 12 of 40
★ FPSC ★ PPSC

What is the output of the following code: char str[] = "Hello"; cout << sizeof(str); in C++?

Question 13 of 40
★ FPSC ★ PPSC

What is the correct way to initialize a string object named 'str' in C++?

Question 14 of 40
★ FPSC ★ PPSC

What is the purpose of the 'strcat()' function in C++?

Question 15 of 40
★ FPSC ★ PPSC

What is the output of the following code: char str[] = "Hello"; cout << str; in C++?

Question 16 of 40
★ FPSC ★ PPSC

Which of the following correctly initializes a two-dimensional array named matrix in C++ with dimensions 3x3?

Question 17 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet in C++? int arr[] = {1, 2, 3, 4, 5}; cout << arr[5];

Question 18 of 40
★ FPSC ★ PPSC

Which of the following correctly defines a string variable named name initialized with the value "John" in C++?

Question 19 of 40
★ FPSC ★ PPSC

What is the purpose of the 'strcmp()' function in C++?

Question 20 of 40
★ FPSC ★ PPSC

Which of the following correctly declares an array of 10 integers in C++ and initializes all elements to zero?

Question 21 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet in C++? char str[] = "Hello"; cout << str[4];

Question 22 of 40
★ FPSC ★ PPSC

In C++, which function is used to read a string with spaces using cin?

Question 23 of 40
★ FPSC ★ PPSC

What is the correct way to access the fifth character in a string variable named text in C++?

Question 24 of 40
★ FPSC ★ PPSC

What is the purpose of the 'toupper()' function in C++?

Question 25 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet in C++? char str[] = "Hello"; cout << sizeof(str);

Question 26 of 40
★ FPSC ★ PPSC

What is the correct way to declare a string object named myString and initialize it with the value "Welcome" in C++?

Question 27 of 40
★ FPSC ★ PPSC

What does the 'strncpy()' function do in C++?

Question 28 of 40
★ FPSC ★ PPSC

What is the purpose of the 'strtok()' function in C++?

Question 29 of 40
★ FPSC ★ PPSC

Which of the following statements is true about array indices in C++?

Question 30 of 40
★ FPSC ★ PPSC

What is the correct way to access the last element of an array named arr in C++?

Question 31 of 40
★ FPSC ★ PPSC

How do you declare a multidimensional array with 3 rows and 4 columns in C++?

Question 32 of 40
★ FPSC ★ PPSC

What is the output of the following code: char str[10]; cout << sizeof(str); in C++?

Question 33 of 40
★ FPSC ★ PPSC

Which function is used to find the first occurrence of a specified substring within a string in C++?

Question 34 of 40
★ FPSC ★ PPSC

What is the output of the following code: char str[] = "Hello"; cout << str[0] << str[4]; in C++?

Question 35 of 40
★ FPSC ★ PPSC

In C++, what is the purpose of the 'cin.getline()' function?

Question 36 of 40
★ FPSC ★ PPSC

How do you declare a string object named 'text' in C++?

Question 37 of 40
★ FPSC ★ PPSC

What is the correct syntax for declaring an array of 5 integers in C++?

Question 38 of 40
★ FPSC ★ PPSC

What is the purpose of the 'cin.ignore()' function in C++?

Question 39 of 40
★ FPSC ★ PPSC

What is the output of the following code: char str[] = "Hello"; cout << strlen(str); in C++?

Question 40 of 40
★ FPSC ★ PPSC

What is the correct syntax to declare a string literal in C++?

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