Welcome Guest | Sign in | Register
Operators - Discussion Page For Q.10674 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Operators > Questions and Answers

Q:  Given the following program fragment, which one of the given option is correct?
main ()
{
int i, j, k;
i = 3;
j =2*(i++);
k =2*(++i);
}
A. j = 6, k = 10. B. i = 5, k = 6.
C. j = 6, k = 8. D. i = 4, j = 6.

Answer and Explanation

Answer:j = 6, k = 10.

Explanation:
In the expression j = 2 * (i++) the value of i is used before incrementing and in expression k =2*(++i); will get incremented first and then used in the expression

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.