Question 1 of 25
Hints left: 3
Q1
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; }
Q2
How do you declare a multidimensional array with 3 rows and 4 columns in C++?
-
A
-
B
-
C
-
D
Q3
What is the output of the following code: char str[] = "Hello"; cout << str[0] << str[4]; in C++?
Q4
What is the correct syntax for declaring an array of 5 integers in C++?
Q5
What is the output of the following code: char str[10]; cout << sizeof(str); in C++?
Q6
In C++, what is the purpose of the 'cin.getline()' function?
Q7
How many maximum number of parameters does a string constructor can take?
Q8
What is the purpose of the 'cin.ignore()' function in C++?
Q9
Which of the following is true regarding the declaration of a string in C++ using the char array?
Q10
How does the strings are stored in the memory?
Q11
What is the difference between unsigned int length() and unsigned int size()?
Q12
Which function is used to find the first occurrence of a specified substring within a string in C++?
Q13
How do you declare a string object named 'text' in C++?
Q14
How do you access the element at the second row and third column of a two-dimensional array named 'matrix' in C++?
Q15
What will happen if a string is empty?
Q16
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; }
Q17
How many parameters can a resize method take?
Q18
What is the output of the following code: char str[] = "Hello"; cout << strlen(str); in C++?
Q19
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; }
Q20
Which is an instantiation of the basic_string class template?
Q21
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; }
Q22
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; }
Q23
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; }
Q24
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; }
Q25
What is the correct syntax to declare a string literal in C++?