What will be the value of x if b = 2 and c = 3?
x = c++ – ++b * ++c;
please tell me the answer fast
Answers
Answer: x = -12
Solution:
Given, b = 2, c = 3
Expression:
x = c++ - ++b * ++c
Evaluation:
x = 3 - 3 * 5
x = 3 - 15
x = -12
Explanation:
The above operators used are all increment operators that work in a way where they increase the value of the variable by 1, depending upon the position of ++ (either before of after the variable).
Prefix Form : ++x
It increments the variables expression then uses the new value in the expression.
Trick to remember - Pehle istemaal krein fir vishwas krein
(Meaning: first increase the value then use it right there)
Postfix Form : x++
The variables value is first used in the expression and then it is incremented after the operation.
Trick to remember - Pehle vishwas krein fir istemaal krein
(Meaning: increase the value but do not use it right there, use it in the next term)
Answer:
x = 9
Explanation:
find x if b = 2 and c = 3
x = c++ - ++b * ++c;
x = 3 - 3 x 4 (c++ = 3, ++b = 3 and ++c = 4)
x = 3 - 12
x = 9