Basic and Advance C Question:

Download Job Interview Questions and Answers PDF

If the assignment operator were ...

C Programming Interview Question
C Programming Interview Question

Answer:

If the assignment operator were :=, wouldn't it then be harder to accidentally write things like if(a = b) ?

Yes, but it would also be just a little bit more cumbersome to type all of the assignment statements which a typical program contains.
In any case, it's really too late to be worrying about this sort of thing now. The choices of = for assignment and == for comparison were made, rightly or wrongly, over two decades ago, and are not likely to be changed. (With respect to the question, many compilers and versions of lint will warn about if(a = b) and similar expressions;
As a point of historical interest, the choices were made based on the observation that assignment is more frequent than comparison, and so deserves fewer keystrokes. In fact, using = for assignment in C and its predecessor B represented a change from B's own predecessor BCPL, which did use := as its assignment operator.

Download C Programming Interview Questions And Answers PDF

Previous QuestionNext Question
Does C have an equivalent to Pascals with statement?Is C a great language, or what?