Given the following problem Whats the output include using n

Given the following problem. What\'s the output? #include using namespace std; main() {int a = 5, b[3] = {1, 2, 3}, *p; cout

Solution

Program:

#include <iostream>
using namespace std;

int main() {
int a=5,b[3]={1,2,3},*p;
cout<<a<<endl; // Here a value is 5
cout<<b<<endl;
cout<<&b[2]<<endl;
p=&b[1]; // Here we are assigning (or) referencing &b[1] value ( i.e address of b[1] ) to p
cout<<p<<endl; // Printing value of p
cout<<&p<<endl; // Here we are printing address of p
p=&a; // Here we are assigning value of a ( i.e 5 ) to p
cout<<&p<<endl; // Here we are again printing address of p
cout<<*p<<endl;
}

Output:

5
0xbf8f3704
0xbf8f370c
0xbf8f3708
0xbf8f3700
0xbf8f3700
5

 Given the following problem. What\'s the output? #include using namespace std; main() {int a = 5, b[3] = {1, 2, 3}, *p; cout SolutionProgram: #include <iost

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site