×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

What will be the output of the following C++ program (2)?

142. What will be the output of the following program?

#include <iostream>
using namespace std;

int main()
{
    int x = 50, y = 20;
    int *p1 = &x, *p2 = &y;
    p1 = p2;

    cout << *p1;

    return 0;
}

Options:

  1. 50
  2. 20
  3. Address
  4. Error

Answer: B) Address

Explanation:

Here, initially, pointer p1 points to variable x, and pointer p2 points to y variable. Then pointer p2 is assigned to pointer p1. So when we print *p2 then it will print the value of variable "y" which is 20.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.