Which should be given first preference | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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

19th Feb 2019, 2:28 PM
QUICK SILVER
QUICK SILVER - avatar
4 Answers
+ 2
Thank u very much for the valuable info and ur time bro
19th Feb 2019, 3:44 PM
QUICK SILVER
QUICK SILVER - avatar
+ 1
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
19th Feb 2019, 2:36 PM
HonFu
HonFu - avatar
0
+ 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
25th Feb 2019, 2:39 PM
Prajwal Anagani
Prajwal Anagani - avatar
0
Thanks
27th Feb 2019, 3:02 AM
QUICK SILVER
QUICK SILVER - avatar