How does this code output this result???(answered, thank you😋) | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How does this code output this result???(answered, thank you😋)

How does my code output 10 instead of 30? https://code.sololearn.com/cPYJKMr07r8o/?ref=app

6th Aug 2021, 1:56 AM
Rishi
Rishi - avatar
6 Antworten
+ 5
More to the point, Rishi, it sees the result of the expression would be (int). That is what really matters. Since it can be determined at compile time, the expression is discarded.
6th Aug 2021, 2:05 AM
Brian
Brian - avatar
+ 3
Rishi the result of the sizeof is determined at compile time. The compiler only determines the type of the sizeof argument and it hard codes the size of the operand. It does not evaluate the operand at run time. So x remains at its initialized value.
6th Aug 2021, 2:02 AM
Brian
Brian - avatar
+ 2
Brian oh yeah I got it, thank you. Have a nice day :)
6th Aug 2021, 2:12 AM
Rishi
Rishi - avatar
0
Brian so you're saying that, it only sees "x" and not "x=x+20"?
6th Aug 2021, 2:04 AM
Rishi
Rishi - avatar
0
Fawad Jan thank you for your comment. That was so helpful
8th Aug 2021, 1:51 AM
Rishi
Rishi - avatar
- 2
سلام
7th Aug 2021, 2:06 PM
Fawad Jan