【转帖】一些经典c/c++题

Some good C++ questions to ask a job applicant.

   1. How do you decide which integer type to use?
   2. What should the 64-bit integer type on new, 64-bit machines be?

   3. What’s the best way to declare and define global variables?
   4. What does extern mean in a function declaration?
   5. What’s the auto keyword good for?
   6. I can’t seem to define a linked list node which contains a pointer to itself.
   7. How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
   8. How can I declare a function that returns a pointer to a function of its own type?
   9. My compiler is complaining about an invalid redeclaration of a function, but I only define it once and call it once. What’s happening?
  10. What can I safely assume about the initial values of variables which are not explicitly initialized?
  11. Why can’t I initialize a local array with a string?
  12. What is the difference between char a[] = “string"; and char *p = “string"; ?
  13. How do I initialize a pointer to a function?
C interview questions(超级经典)ZZ
      里边的不少题目在自己面试笔试时都常考到……感觉这些要是都掌握了,真的无往而不利啊……嘿咻嘿咻

 

  1. What is a pointer?
  2. What is a structure?
  3. What are the differences between structures and arrays?
  4. In header files whether functions are declared or defined?
  5. What are the differences between malloc() and calloc()?
  6. What are macros? What are the advantages and disadvantages?
  7. Difference between pass by reference and pass by value?
  8. What is static identifier?
  9. Where are the auto variables stored?
  10. Where does global, static, local, register variables, free memory and C Program instructions get stored?
  11. Difference between arrays and linked list?
  12. What are enumerations?
  13. Describe about storage allocation and scope of global, extern, static, local and register variables?
  14. What are register variables? What are the advantage of using register variables?
  15. What is the use of typedef?
  16. Can we specify variable field width in a scanf() format string? If possible how?
  17. Out of fgets() and gets() which function is safe to use and why?
  18. Difference between strdup and strcpy?
  19. What is recursion?
  20. Differentiate between a for loop and a while loop? What are it uses?
  21. What are the different storage classes in C?
  22. Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
  23. What is difference between Structure and Unions?
  24. What the advantages of using Unions?
  25. What are the advantages of using pointers in a program?
  26. What is the difference between Strings and Arrays?
  27. In a header file whether functions are declared or defined?
  28. What is a far pointer? where we use it?
  29. How will you declare an array of three function pointers where each function receives two ints and returns a float?
  30. What is a NULL Pointer? Whether it is same as an uninitialized pointer?
  31. What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
  32. What does the error ‘Null Pointer Assignment’ mean and what causes this error?
  33. What is near, far and huge pointers? How many bytes are occupied by them?
  34. How would you obtain segment and offset addresses from a far address of a memory location?
  35. Are the expressions arr and *arr same for an array of integers?
  36. Does mentioning the array name gives the base address in all the contexts?
  37. Explain one method to process an entire string as one unit?
  38. What is the similarity between a Structure, Union and enumeration?
  39. Can a Structure contain a Pointer to itself?
  40. How can we check whether the contents of two structure variables are same or not?
  41. How are Structure passing and returning implemented by the complier?
  42. How can we read/write Structures from/to data files?
  43. What is the difference between an enumeration and a set of pre-processor # defines?
  44. What do the ‘c’ and ‘v’ in argc and argv stand for?
  45. Are the variables argc and argv are local to main?
  46. What is the maximum combined length of command line arguments including the space between adjacent arguments?
  47. If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
  48. Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
  49. What are bit fields? What is the use of bit fields in a Structure declaration?
  50. To which numbering system can the binary number 1101100100111100 be easily converted to?
  51. Which bit wise operator is suitable for checking whether a particular bit is on or off?
  52. Which bit wise operator is suitable for turning off a particular bit in a number?
  53. Which bit wise operator is suitable for putting on a particular bit in a number?
  54. Which bit wise operator is suitable for checking whether a particular bit is on or off?
  55. Which one is equivalent to multiplying by 2?
    • Left shifting a number by 1
    • Left shifting an unsigned int or char by 1?
  56. Write a program to compare two strings without using the strcmp() function.
  57. Write a program to concatenate two strings.
  58. Write a program to interchange 2 variables without using the third one.
  59. Write programs for String Reversal. The same for Palindrome check.
  60. Write a program to find the Factorial of a number.
  61. Write a program to generate the Fibonacci Series?
  62. Write a program which employs Recursion?
  63. Write a program which uses command line arguments.
  64. Write a program which uses functions like strcmp(), strcpy(), etc.
  65. What are the advantages of using typedef in a program?
  66. How would you dynamically allocate a one-dimensional and two-dimensional array of integers?
  67. How can you increase the size of a dynamically allocated array?
  68. How can you increase the size of a statically allocated array?
  69. When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
  70. Which function should be used to free the memory allocated by calloc()?
  71. How much maximum can you allocate in a single call to malloc()?
  72. Can you dynamically allocate arrays in expanded memory?
  73. What is object file? How can you access object file?
  74. Which header file should you include if you are to develop a function which can accept variable number of arguments?
  75. Can you write a function similar to printf()?
  76. How can a called function determine the number of arguments that have been passed to it?
  77. Can there be at least some solution to determine the number of arguments passed to a variable argument list function?
  78. How do you declare the following:
    • An array of three pointers to chars
    • An array of three char pointers
    • A pointer to array of three chars
    • A pointer to function which receives an int pointer and returns a float pointer
    • A pointer to a function which receives nothing and returns nothing
  79. What do the functions atoi(), itoa() and gcvt() do?
  80. Does there exist any other function which can be used to convert an integer or a float to a string?
  81. How would you use qsort() function to sort an array of structures?
  82. How would you use qsort() function to sort the name stored in an array of pointers to string?
  83. How would you use bsearch() function to search a name stored in array of pointers to string?
  84. How would you use the functions sin(), pow(), sqrt()?
  85. How would you use the functions memcpy(), memset(), memmove()?
  86. How would you use the functions fseek(), freed(), fwrite() and ftell()?
  87. How would you obtain the current time and difference between two times?
  88. How would you use the functions randomize() and random()?
  89. How would you implement a substr() function that extracts a sub string from a given string?
  90. What is the difference between the functions rand(), random(), srand() and randomize()?
  91. What is the difference between the functions memmove() and memcpy()?
  92. How do you print a string on the printer?
  93. Can you use the function fprintf() to display the output on the screen?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值