C Interview Questions & Answers part 3
We can not modify the constant variable.
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: – Why n++ executes faster than n+1?
n++ executes faster than n+1 because n++ want only one instruction for execution where n+1 want more one instruction for execution.
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 can you do with the enum data type?
The enum data type can be used to declare names that represent integer constants.
Q: – What is the difference between the Heap and the Stack?
The main difference b/n the Heap and the Stack are given below:
– In stack we create object temporary where programmer used to reserve allocation.'
– stack not have automatic garbage collection where as heap have automatic garbage collection.
Submitted By:-Rohit Kumar Email-ID: – firstname.lastname@example.org