Monday 18 March 2013

printf("i = %d, -i = %d \n",i,-i);



    main()
    {
    int i=-1;
    -i;
    printf("i = %d, -i = %d \n",i,-i);
    }
Answer:
i = -1, -i = 1
Explanation:
-i is executed and this execution doesn't affect the value of i. In printf first you just print the value of i. After that the value of the expression -i = -(-1) is printed.


Blog Author: Vijay Kumar

Go to: Java Aptitude

No comments:

Post a Comment