60 625
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #3089 in C++ for wizzy

Question #3089
A variable n of data type int is assigned a value 10 and accessed via a pointer ipt. After an increment of 2 on the value of ipt , what will become the value of n?
write out the code for this task
Expert's answer

May be you missed something in your question so we'd analyzed all cases:

void operation1(int * ipt) //2+ipt
{
int a=2;
a+=ipt; //types do not match. a-int ipt-int*. error while compilation
}

void operation2(int * ipt) //2+(*ipt) - as for me this one match to
your question
{
& int a=2;
a+=*ipt; //a=12, n does not change
}

void operation3(int * ipt) //(*ipt)+2
{
int a=2;
*ipt+=a; //n=12, a does not change (a=2)
}

void main()
{
int n=10;
operation1(&n);
operation2(&n);
operation3(&n);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions