why do some people write if(0 == x) instead of if(x == 0)?



why do some people write if(0 == x) instead of if(x == 0)?..

Answer / Yogendra Pratap Singh

Some developers write if(0 == x) to make the code easier to read, as it's clear that you're testing for zero and not accidentally comparing a variable to an unknown value. In C, both expressions are equivalent.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is string function c?

1 Answers  


code snippet for creating a pyramids triangle ex 1 2 2 3 3 3

4 Answers  


Why c is called a middle level language?

1 Answers  


What is the real difference between arrays and pointers?

27 Answers   Hexaware, Logic Pro, TCS,


char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)

7 Answers   Mascot,


main() { intj; while9j<=10) { printf("\n%d",j); j=j+1; } }

4 Answers  


Write a program for Overriding.

1 Answers  


n=7623 { temp=n/10; result=temp*10+ result; n=n/10 }

7 Answers   Wipro,


who developed c and why he developed c?

5 Answers  


What are keywords in c with examples?

1 Answers  


Why cd or dvd are round why not square.

1 Answers  


When should a type cast not be used?

1 Answers  


Categories