0 0 votes main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); } Programming in C programming-in-c pointers output + – Desert_Warrior 1.2k views answer comment Share Follow Print See all 3 Comments 3 3 Comments reply shivanisrivarshini commented May 16, 2016 reply Follow flag i=-1 -i=1 0 0 replyShare Desert_Warrior commented May 16, 2016 reply Follow flag my question is why that unary minus does not have any effect? 0 0 replyShare shivanisrivarshini commented May 16, 2016 reply Follow flag Unary minus here is just displayed -ve value but no effect on the original value if we have i=-i then effect is shown but -i is not stored --i = that i=i-1 representation so it is stored in i 1 1 replyShare Please log in or register to add a comment.
Best answer 4 4 votes main() { int i=-1; // This will store -1 in i -i; // This will not have any effect on i as you are not asigning that in i printf("i = %d, -i = %d \n",i,-i); // First will print value of i which is -1 // Second will print value of -i which is 1 } Hence the output will be -1 1 rude answered May 17, 2016 • selected May 17, 2016 by Desert_Warrior rude comment Share Follow 0 reply Please log in or register to add a comment.