C Programming - Expressions - Discussion
Discussion Forum : Expressions - General Questions (Q.No. 6)
6.
In which order do the following gets evaluated
1. | Relational |
2. | Arithmetic |
3. | Logical |
4. | Assignment |
Answer: Option
Explanation:
2. Arithmetic operators: *, /, %, +, -
1. Relational operators: >, <, >=, <=, ==, !=
3. Logical operators : !, &&, ||
4. Assignment operators: =
Discussion:
9 comments Page 1 of 1.
Abhayraj SN said:
9 years ago
a + b > c ! d = e
Without specifying brackets, how we solve above expression and how it will give us the answer?
If done sequentially is right, given answer is right, else someone please suggest for it.
Without specifying brackets, how we solve above expression and how it will give us the answer?
If done sequentially is right, given answer is right, else someone please suggest for it.
(1)
Vinaya said:
8 years ago
Please sir, can you explain with an example?
(1)
Ravi korde said:
7 years ago
Please give a clear explanation.
(1)
Bhargavi said:
6 years ago
#include <stdio.h>
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y && z++;
printf("%d", z);
}
Can you Explain this code please?
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y && z++;
printf("%d", z);
}
Can you Explain this code please?
(1)
Hardik patel said:
5 years ago
According to associativity of operators first priority is goes to logical operator than Arithmetic than relation and than assignment in gcc environment.
(1)
Neeraj Kumar Malviya said:
4 years ago
Please explain me the answer.
(1)
Rupinderjit said:
1 decade ago
Here ! is exceptional case. It has high precedence over all the options mentioned above, though it's logical operator.
Srikanth alladi said:
1 decade ago
To give an better example consider:
z = (a + b)>(c * b) ! (b * a)>(c + b).
First arithmetic will be solved, then relational, logical and at last assignment.
z = (a + b)>(c * b) ! (b * a)>(c + b).
First arithmetic will be solved, then relational, logical and at last assignment.
Magesh Gopal said:
1 decade ago
No. the above example. (..) is the high precedence.
Take this:
a= !b + !c;
Now "!" is first happen.
Take this:
a= !b + !c;
Now "!" is first happen.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers