What will be printed out as a result of the following code execution?

#include <iostream>
using namespace std;

int main()
{
    int * ap; 
    int * bp; 

    int a[2] = { 5, 50 }; 
    int b[2] = { 1, 10 }; 
    
    ap = a;
    bp = b;

    ap = bp;   
    cout << *ap+1;  

    return 0;
}
Explanation
Before output ap will point to content of array b. *ap will return first element of array b, which is 1 and 1+1=2
C++
C++ Quiz
Start Quiz

or Read more about C++ Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback