C Programming - Expressions - Discussion

Discussion Forum : Expressions - General Questions (Q.No. 4)
4.
Which of the following is the correct order if calling functions in the below code?
a = f1(23, 14) * f2(12/4) + f3();
f1, f2, f3
f3, f2, f1
Order may vary from compiler to compiler
None of above
Answer: Option
Explanation:
Here, Multiplication will happen before the addition, but in which order the functions would be called is undefined. In an arithmetic expression the parenthesis tell the compiler which operands go with which operators but do not force the compiler to evaluate everything within the parenthesis first.
Discussion:
12 comments Page 2 of 2.

Akhil said:   8 years ago
The () doesn't have the highest precedence but grouping is more visible with high precedence operators. take a case:

int x=3,y=5,p=10,z;
z = (x>y)||(x==0)&&(y<<1);
printf("%d",z);

The output should be like (x>y)||(x==0) evaluated first and then the and operation. but as and has higher precedence, it forma a group leading to evaluation of (x>y) first and then anding with ((x==0)&&(y<<1)).

If you get the thing then try to answer the above question.
z=1
i.e; false.

Akash c said:   4 years ago
Logic operators always tell true or false. if it false, then ans =0 if it's right then ans =1.
I think the answer will be 0!!!
Is it correct?


Post your comments here:

Your comments will be displayed after verification.