Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. ============================
- #include <iostream>
- using namespace std;
- int main()
- {
- int a = 32, *ptr = &a;
- char ch = 'A', &cho = ch;
- cho += a;
- *ptr += ch;
- cout << a << ", " << ch << endl;
- return 0;
- }
- Options:
- a. 32, A
- b. 32, a
- c. 129, a
- d. 129, A
- 2.============================
- #include <iostream>
- using namespace std;
- int main()
- {
- const int i = 20;
- const int* const ptr = &i;
- (*ptr)++;
- int j = 15;
- ptr = &j;
- cout << i;
- return 0;
- }
- Options:
- a. 20
- b. 21
- c. 15
- d. Compile error
- 3. ============================
- #include <iostream>
- using namespace std;
- int main()
- {
- int num[5];
- int* p;
- p = num;
- *p = 10;
- p++;
- *p = 20;
- p = &num[2];
- *p = 30;
- p = num + 3;
- *p = 40;
- p = num;
- *(p + 4) = 50;
- for (int i = 0; i < 5; i++)
- cout << num[i] << ", ";
- return 0;
- }
- Options:
- a. 10, 20, 30, 40, 50
- b. 10, 20, 30, 40, 50,
- c. compile error
- d. runtime error
- 4. ============================
- #include <iostream>
- using namespace std;
- int main()
- {
- int arr[] = { 4, 5, 6, 7 };
- int* p = (arr + 1);
- cout << *arr + 10;
- return 0;
- }
- Options:
- a. 12
- b. 15
- c. 14
- d. error
- 5. ===========================
- #include <iostream>
- using namespace std;
- int main()
- {
- int a = 10, *pa, &ra;
- pa = &a;
- ra = a;
- cout << "a=" << ra;
- return 0;
- }
- Options:
- a. 10
- b. no output
- c. compile error
- d. runtime error
Advertisement
Add Comment
Please, Sign In to add comment