Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include<iostream> using namespace std; int main() { int x = 10; int& ref = x; ref = 20; cout << x << endl ; x = 30; cout << ref << endl; return 0; }
Q2
Pick the correct statement about references.
Q3
What will be the output of the following C++ code? #include <iostream> using namespace std; void print (char * a) { cout << a << endl; } int main () { const char * a = "Hello world"; print(const_cast (a) ); return 0; }
Q4
How to declare a wide character in the string literal?
Q5
Which of the following function must use reference.
Q6
What will be the output of the following C++ code? #include <iostream> using namespace std; void swap(int &a, int &b); int main() { int a = 5, b = 10; swap(a, b); cout << "In main " << a << b; return 0; } void swap(int &a, int &b) { int temp; temp = a; a = b; b = temp; cout << "In swap " << a << b; }
Q7
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int &p = a; cout<<p; return 0; }
Q8
How are the constants declared?
Q9
The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is . . . . . . . .
Q10
The pointer can point to any variable that is not declared with which of these?
Q11
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = a; cout<<*p<<endl; cout<<*q<<endl; return 0; }
Q12
Identify the incorrect statement.
Q13
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 5, b = 10, c = 15; int *arr[ ] = {&a, &b, &c}; cout << arr[1]; return 0; }
Q14
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char *ptr; char Str[] = "abcdefg"; ptr = Str; ptr += 5; cout << ptr; return 0; }
Q15
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24}; cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]]; return 0; }
Q16
Pick the correct statement about references in C++.
Q17
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i; char c; void *data; i = 2; c = 'd'; data = &i; cout << "the data points to the integer value" << data; data = &c; cout << "the data now points to the character" << data; return 0; }
Q18
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i; const char *arr[] = {"C", "C++", "Java", "VBA"}; const char *(*ptr)[4] = &arr; cout << ++(*ptr)[2]; return 0; }
Q19
What is size of generic pointer in C++ (in 32-bit platform)?
Q20
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; void func(const int &a) { int temp = 10; a = temp; cout<<a; } int main(int argc, char const *argv[]) { int a = 5; func(a); return 0; }
Q21
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int n = 5; void *p = &n; int *pi = static_cast<int*>(p); cout << *pi << endl; return 0; }
Q22
Regarding the following statement which of the statements is true? const int a = 100;
Q23
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = a; cout<<p<<endl; cout<<q<<endl; return 0; }
Q24
What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int numbers[5]; int * p; p = numbers; *p = 10; p++; *p = 20; p = &numbers[2]; *p = 30; p = numbers + 3; *p = 40; p = numbers; *(p + 4) = 50; for (int n = 0; n < 5; n++) cout << numbers[n] << ","; return 0; }
Q25
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int &q = a; cout<<&a<<endl; cout<<&q<<endl; return 0; }