Which should be given first preference | Sololearn: Learn to code for FREE!


Which should be given first preference

If we give preference as stated in the lesson if we give preference as * / % + - Then if we execute program with a=6 b=4 c=2 then when we print result for Result=a-b+c It is showing output 4 But as per the order mentioned above we should get output of 0 so please Give me the original precedance which is perfect to be followed plz help me guys

2/19/2019 2:28:19 PM


4 Answers

New Answer


Thank u very much for the valuable info and ur time bro


It might be quite a bit to read, but this should answer your question for C: https://en.cppreference.com/w/c/language/operator_precedence


+ and - have the same priority (precedence) , therefore whichever operation comes first, that one is executed. If you try b+c-a you would get 0