Interview Questions

C/C++ Questions only (Miscellaneous)

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


(Continued from previous question...)

C/C++ Questions only (Miscellaneous)

1. How can I return multiple values from a function?

2. How do I access command-line arguments?

3. How can I write data files which can be read on other machines

with different data formats?

4. How can I call a function, given its name as a string?

5. How can I implement sets or arrays of bits?

6. How can I determine whether a machine's byte order is big-endian

or little-endian?

7. How can I convert integers to binary or hexadecimal?

8. Can I use base-2 constants (something like 0b101010)?

Is there a printf format for binary?

9. What is the most efficient way to count the number of bits which

are set in a value?

10. How can I make my code more efficient?

11. Are pointers really faster than arrays? How much do function

calls slow things down?

12. Is there a way to switch on strings?

13. Is there a way to have non-constant case labels (i.e. ranges or

arbitrary expressions)?

14. Are the outer parentheses in return statements really optional?

15. Why don't C comments nest? Are they legal inside quoted strings?

16. Why doesn't C have nested functions?

17. How can I call FORTRAN (C++, BASIC, Pascal, Ada, LISP) functions from C?

16. Does anyone know of a program for converting Pascal or FORTRAN to C?

17. Can I use a C++ compiler to compile C code?

18. I need to compare two strings for close, but not necessarily exact, equality.

19. What is hashing?

20. How can I find the day of the week given the date?

21. Will 2000 be a leap year?

22. How do you write a program which produces its own source code as

its output?

23. What is ``Duff's Device''?

24. When will the next Obfuscated C Code Contest be held? How can I

get a copy of previous winning entries?

25. What was the entry keyword mentioned in K&R1?

26. Where does the name ``C'' come from, anyway?

27. How do you pronounce ``char''?

28. Where can I get extra copies of this list?

Other Interview Questions