Question: The following are different programs that implement pointers. What would be the result of each ? Explain in details the concept of each line of

The following are different programs that implement pointers. What would be the result of
each ? Explain in details the concept of each line of below codes.
1 #include
using namespace std;
int main()
{//Assume that the address of the variable a =0015FAA0
int a;
int *aPtr;
a =7;
aPtr = &a;
cout << &a << endl;
cout << aPtr << endl;
cout << a << endl;
cout <<*aPtr << endl;
cout << &*aPtr << endl;
cout <<*&aPtr << endl;
return 0;}
2 #include
using namespace std;
int main ()
{ int num1, num2;
int *mypointer;
mypointer = &num1;
*mypointer =10;
mypointer = &num2;
*mypointer =20;
cout << "firstvalue is "<< num1<< endl;
cout << "secondvalue is "<< num2<< endl;
return 0;}
3 #include
using namespace std;
int main ()
{
int firstvalue =5, secondvalue =15;
int *p1,*p2;
p1= &firstvalue;
p2= &secondvalue;
*p1=10;
*p2=*p1;
p1= p2;
*p1=20;
cout << "firstvalue is "<< firstvalue << endl;
cout << "secondvalue is "<< secondvalue << endl;
return 0;
}
4 #include
using namespace std;
void double_it_1(int *p)
{
*p =*p *2;
}
void double_it_2(int n)
{
n = n*2;
}
int main(){
int var =10;
int *pvar = &var;
cout <<*pvar <

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!