Home » 
        MCQs » 
        C++ MCQs
    
        
    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:
    
      - 50
- 20
- Address
- 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.