C Programming - Expressions - Discussion

Discussion Forum : Expressions - General Questions (Q.No. 2)
2.
Which of the following correctly shows the hierarchy of arithmetic operations in C?
/ + * -
* - / +
+ - / *
/ * + -
Answer: Option
Explanation:

Simply called as BODMAS (Bracket of Division, Multiplication, Addition and Subtraction).

How Do I Remember ? BODMAS !

  • B - Brackets first
  • O - Orders (ie Powers and Square Roots, etc.)
  • DM - Division and Multiplication (left-to-right)
  • AS - Addition and Subtraction (left-to-right)
  • Discussion:
    13 comments Page 1 of 2.

    Aditi Naikwadi said:   3 years ago
    The correct ans is */%+- =.

    Alekhya said:   5 years ago
    Yes, the correct answer is */+-.

    BODMAS is when you solve normal mathematical operations but in C it is not same.

    Dilip said:   7 years ago
    As per my knowledge the Correct answer is */%+-.

    Debsena Sadhukhan said:   7 years ago
    what should be followed?

    * / % + - =
    or
    / * + - to evaluate arithmetic expressions?

    Arjun singh said:   7 years ago
    The correct answer is */+-.

    Amitabha Das said:   8 years ago
    I don't think this answer should be valid because according to C, division & multiplication have same precedence only thing is that they are left associative, same for + and -.

    Prashant said:   8 years ago
    The correct answer is * / % + -.

    Md Jahid said:   10 years ago
    Answer is incorrect priority is:

    *
    /
    %
    +
    -

    Vennela said:   1 decade ago
    Precedence of operators in an expression:

    1. () [] L to R.
    2. +
    -
    ++
    --
    !
    *
    &
    sizeof
    3. *,/,%(L to R).
    4. +,-(L to R).
    5. <<,>>(L to R).
    6. <,<=,,>,>=(L to R).
    7. &(L to R).
    9. ^
    10. !
    11. &&
    12. ||
    13. ?:
    14. =
    += /=
    %= -=
    <<= >>=
    != &=
    /=

    Shriram Saxena said:   1 decade ago
    The priority will be:

    1. *, /, % left to right.

    2. +, - left to right.


    Post your comments here:

    Your comments will be displayed after verification.