Interview Questions

C/C++ Questions only (Expressions)

C++ programming on UNIX, C++ Networking,C++ Algorithm Questions and Answers


(Continued from previous question...)

C/C++ Questions only (Expressions)

1. Why doesn't the code "a[i] = i++;" work?

2. Under my compiler, the code "int i = 7; printf("%d\n", i++ *

i++);" prints 49. Regardless of the order of evaluation, shouldn't it

print 56?

3. How could the code [CENSORED] ever give 7?

4. Don't precedence and parentheses dictate order of evaluation?

5. But what about the && and || operators?

6. What's a ``sequence point''?

7. So given "a[i] = i++;" we don't know which cell of a[] gets

written to, but i does get incremented by one.

8. If I'm not using the value of the expression, should I use i++ or

++i to increment a variable?

9. Why doesn't the code "int a = 1000, b = 1000; long int c = a *

b;" work?

10. Can I use ?: on the left-hand side of an assignment expression?

(Continued on next question...)

Other Interview Questions