int i,j=4;
i=j++*++j*j--;
what is the result of i and how it is evaluated please help me.
the result is 125 and i don't understand the evaluation part
satish_dukkipat 0 Newbie Poster
Recommended Answers
Jump to PostThe above is undefined behavior in C?C++
https://www.securecoding.cert.org/confluence/display/cplusplus/EXP34-C.+Do+not+depend+on+order+of+evaluation+between+sequence+points
This code in Java & C# is defined, I would be:int i,j=4; i=j++*++j*j--;
i = 4(5) *(6)6 * 6(5) = 144- Which is what I got when running the program in Java...
Jump to PostIndeed it seems that the only thing which standard says concerning the unary ++ and -- operators, is that the value of the operand would be obtained for use in expression, either before (postfix) or after (prefix) applying the operator. What remains unspecified is the order of evaluation of the …
Jump to PostI think I have a couple questions if you don't mind.
Is there any authoritative book or work that describe all the undefined behaviors in C?.
Or are you suppose to guess when you read the Standards that whatever is not written there is undefined behaviour?
Since we are …
All 12 Replies
Aia 1,977 Nearly a Posting Maven
Salem commented: Please revisit http://www.daniweb.com/forums/thread83018.html -2
iamthwee commented: Nope. -2
SirJames 10 Newbie Poster
Salem commented: Good answer +10
TkTkorrovi 69 Junior Poster
Aia commented: Nothing but gcc. +6
Aia 1,977 Nearly a Posting Maven
Salem 5,265 Posting Sage
TkTkorrovi 69 Junior Poster
vvidyadhara 0 Newbie Poster
TkTkorrovi 69 Junior Poster
vvidyadhara 0 Newbie Poster
Salem 5,265 Posting Sage
nam123 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.