C Programming Interview Questions and Answers-4

Q: – Why do we need function prototypes?
With the help of a function prototype, the compiler can automatically perform type checking on the definition of the function, which saves you time in debugging the program.
Q: – Can a function return a pointer?
Yes
Q: – Why do you need to use arrays of pointers?
It is convenient to use an array of pointers to point to a set of character strings so that you can access any one of the strings referenced by a corresponding pointer in the array.
Q: – What does it mean if the malloc() function returns a null pointer?
If the malloc() function returns a null pointer, it means the function failed to allocate a block of memory whose size is specified by the argument passed to the function.
Q: – What are the differences between the calloc() and malloc() functions?
The calloc() function takes two arguments, while the malloc() function takes only one. The second difference is that the calloc() function initializes the allocated memory space to 0, whereas there is no such guarantee made by the malloc() function.
Q: – Is the free() function necessary?
Yes. The free() function is very necessary, and you should use it to free up allocated memory blocks as soon as you don’t need them.
Q: – What can you do with the enum data type?
The enum data type can be used to declare names that represent integer constants.
Q: – Why do you need to use the typedef keyword?
By using the typedef keyword, you can define your own names to represent the data types in C.
Q: – Can you redirect a standard stream to a disk file?
Yes. With the help of the freopen() function, you can redirect a standard stream and associate the stream with a disk file.
Q: – Is the C preprocessor part of the C compiler?
No

Tagged , . Bookmark the permalink.

Leave a Reply