Basic and Advance C Question:

Download Job Interview Questions and Answers PDF

People claim that optimizing compilers are good and that we no longer have to write things in assembler for speed

C Programming Interview Question
C Programming Interview Question

Answer:

People claim that optimizing compilers are good and that we no longer have to write things in assembler for speed, but my compiler can't even replace i/=2 with a shift.

Was i signed or unsigned? If it was signed, a shift is not equivalent (hint: think about the result if i is negative and odd), so the compiler was correct not to use it.

Download C Programming Interview Questions And Answers PDF

Previous QuestionNext Question
How can I swap two values without using a temporary?I have been replacing multiplications and divisions with shift operators, because shifting is more efficient.