Interview Questions

But what about... I see code like ?

C Interview Questions and Answers


(Continued from previous question...)

But what about... I see code like ?

Q : But what about the && and || operators?
I see code like ``while((c = getchar()) != EOF && c != '\n')''

A: There is a special ``short-circuiting'' exception for these operators: the right-hand side is not evaluated if the left-hand side determines the outcome (i.e. is true for || or false for &&). Therefore, left-to-right evaluation is guaranteed, as it also is for the comma operator. Furthermore, all of these operators (along with ?:) introduce an extra internal sequence point

(Continued on next question...)

Other Interview Questions