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