Question 1 of 25
Hints left: 3
Q1
Which of the following accesses the seventh element stored in array?
Q2
Which of the following correctly declares an array?
Q3
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; }
Q4
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; }
Q5
What does the 'nullptr' keyword replace in C++11 and later versions?
Q6
What is the index number of the last element of an array with 9 elements?
Q7
What is a pointer in C++?
Q8
What is the purpose of the 'nullptr' keyword in C++?
Q9
How do you declare a pointer variable in C++?
Q10
What is the purpose of the 'reference' in C++?
Q11
Which of the following gives the memory address of the first element in array?
Q12
Which character is used to terminate the string?
Q13
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; }
Q14
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; }
Q15
What is the correct syntax to dereference a pointer in C++?
Q16
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; }
Q17
Which header file is used to manipulate the string?
Q18
What is the output of the following code: int x = 5; int *ptr = &x; cout << *ptr; in C++?
Q19
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; }
Q20
Which constant member functions does not modify the string?
Q21
What is the output of the following code: int x = 5; int &ref = x; cout << ref; in C++?
Q22
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; }
Q23
What is the correct definition of an array?
Q24
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; }
Q25
Where are the strings stored?