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 !
Discussion:
13 comments Page 1 of 2.
Md Jahid said:
10 years ago
Answer is incorrect priority is:
*
/
%
+
-
*
/
%
+
-
(1)
Prashant said:
8 years ago
The correct answer is * / % + -.
(1)
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 -.
(1)
Kiran said:
1 decade ago
Do you give more information about BODMAS. ?.
I want to know all hierarichies.
I want to know all hierarichies.
Kapil said:
1 decade ago
And what about % mod?
Vikas said:
1 decade ago
The given answer is incorrect the priority is:
highest- *
/
%
+
-
i.e. multiplication has higher priority than division.
highest- *
/
%
+
-
i.e. multiplication has higher priority than division.
Shriram Saxena said:
1 decade ago
The priority will be:
1. *, /, % left to right.
2. +, - left to right.
1. *, /, % left to right.
2. +, - left to right.
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. =
+= /=
%= -=
<<= >>=
!= &=
/=
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. =
+= /=
%= -=
<<= >>=
!= &=
/=
Arjun singh said:
8 years ago
The correct answer is */+-.
Debsena Sadhukhan said:
7 years ago
what should be followed?
* / % + - =
or
/ * + - to evaluate arithmetic expressions?
* / % + - =
or
/ * + - to evaluate arithmetic expressions?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers