Vidyalelo
C++ Programming · all questions

Arrays and Strings in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

72

Questions

2/4

Page

Pick an option on a question to see the right answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.