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