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
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);
}