Monday, May 31, 2010

C Questions

As a C programmer you would like to give some thought to following C question.

  1. Can structures be passed to the functions by value?
  2. Why cannot arrays be passed by values to functions?
  3. What are advantages and disadvantages of using macro and inline functions?
  4. What happens when recursion functions are declared inline?
  5. What is scope of static variables?
  6. What is the output of printf("\nab\bcd\ref"); C statement?
  7. #define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but gives preprocessor warning. Why?
  8. Is it possible to define a constant volatile variable? 
  9. Is it possible to define a volatile pointer?
  10. What does ++*ip increments?
  11. Describe an operation involving unsigned and signed.
  12. a+++b;
  13. Is this C statement valid? malloc(sizeof(0))
  14. main() {fork();fork();fork();printf("hello world"); }
  15. what is void (*fptr[10])()?
  16. Which way of writing infinite loops is more efficient than others?
  17. # error — what it does? 
  18. How is function itoa() written?
  19. How to know whether system uses big endian or little endian format and how to convert among them?
  20. What is forward reference w.r.t. pointers in c?
  21. How is generic list manipulation function written which accepts elements of any kind?
  22. How can you define a structure with bit field members?
  23. How do you write a function which takes 2 arguments - a byte and a field in the byte and returns the value of the field in that byte?
  24. What are the different storage classes in C?
  25. What are the different qualifiers in C?
  26. What is void pointer and what is its use?
  27. What is lvalue and rvalue?
  28. Using a variable define these -
    1. An integer
    2. A pointer to integer
    3. A pointer to a pointer integer
    4. An array of 10 integer
    5. An array of 10 pointer to integer
    6. A pointer to an array of 10 integer
    7. A pointer to a function that takes an integer as an argument and returns an integer
    8. An array of 10 pointer to function that take an integer and return an integer
  29. What do the following declarations mean?
    1. const int a;
    2. int const a;
    3. const int *a;
    4. int * const a;
    5. int const* a const;
  30. Is 3[myIntArr] = 5; valid where myIntArr is an array of 10 integers?

No comments:

Post a Comment