1 1 vote consider the foloowing program: int main() { int var1=35, *var2,*var3; var2=&var1;//suppose address of var1 1006 var3=var2; *var2++=*var3++; var1++; printf("var1=%d var2=%d var3=%d",var1,var2,var3); return0; } output print by above program ? Programming in C programming-in-c + – srestha 1.3k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 2 2 votes int main() { int var1=35, *var2,*var3; var2=&var1; //means var2 also ponts to var1 var3=var2; // means var3 also point to var1 *var2++=*var3++; //means value at var2 address will be replced by value at var3 address which is same i.e. 35 no change, after that var2 and var3 adress is incermented means point to location which contain garbage i.e. 1010 , 1010 var1++; // var1 value increament by 1 = var1= 36 printf("var1=%d var2=%d var3=%d",var1,var2,var3); // 36 , 1010 ,1010 since i aasume pointer take 4 Byte so 1006 +4 = 1010 return0; } Prashant. answered Aug 10, 2016 • selected Aug 12, 2016 by srestha Prashant. comment Share Follow See all 7 Comments 7 7 Comments reply ManojK commented Aug 10, 2016 reply Follow flag output should be 36,1010,1010 rt? 2 2 replyShare srestha commented Aug 10, 2016 reply Follow flag yeah , explain 0 0 replyShare ManojK commented Aug 11, 2016 reply Follow flag *var2++=*var3++; The var2 and var3 are inceremnted to point the next integer location which will be 1010 asuming that var2 and var3 contains 1006 before increment. But before the incementation what is done here is assigment.Since post incement after the variable name var2 and var3.. During assigmnet ,the value at the address contained in var2 is replaced by the value at the address contained in var3. And finally value of variable var1 is incremented to 36. 2 2 replyShare Prashant. commented Aug 11, 2016 reply Follow flag ur assuming size of pointer is 4bytes rt? 0 0 replyShare ManojK commented Aug 11, 2016 reply Follow flag yes. 0 0 replyShare srestha commented Aug 11, 2016 reply Follow flag *var2++=*var3++ here we are incrementing *var2 and *var3 //i.e. value at var2 or var3 So, why value at var2 or value at var3 not incremented why address of that position is incremented? is it for precedence of ++ is more than *? 1 1 replyShare ManojK commented Aug 11, 2016 reply Follow flag yes http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm 1 1 replyShare Please log in or register to add a comment.