Write the value stored in c and d.
int a=5,b=3;
int c=a* b++;
int d=a* ++b;
Answers
Answered by
7
Question :
Write the value stored in c and d.
Given :
int a = 5
int b = 3
To Find :
int c - ?
int d - ?
Solution :
• Int C - a * b++
b++ = b + 1 ( Post increment Operator )
- a = 5
- b = 3
= b++
= b + 1
= 3 + 1
= 4
Int C = 5 * 4
Int C = 20
• Int d = a * ++b
++b = 1 + b ( Preincrement Operator )
- a = 5
- b = 3
= ++b
= 1 + b
= 1 + 3
= 4
Int d = 5 * 4
Int d = 20
∴ Value Stored in int c and d is 20
Here, in Int C, the operator is PostIncrement (b++)
In Int d, the operator is Preincrement (++b)
Similar questions