Which of the following is the correct way to define a function that takes no parameters and returns no value?
Avoid function() { }
Bnull function() { }
Cempty function() { }
Dvoid function(void) { }
Correct Answer:
A. void function() { }
Explanation:
In C, void function() { } is correct. In some contexts, void function(void) { } is more explicit. Options B and C use invalid keywords for this purpose.
What is the difference between calloc() and malloc()?
Acalloc() initializes memory to zero, malloc() does not
Bmalloc() is faster than calloc()
Ccalloc() takes two arguments, malloc() takes one
DAll of the above
Correct Answer:
D. All of the above
Explanation:
calloc(n, size) allocates n blocks of size bytes and initializes to 0. malloc(size) allocates size bytes without initialization. calloc() is typically slower due to initialization.
iGET uses cookies for essential site functionality, analytics, and ads personalization (via Google AdSense). By clicking "Accept", you consent to our use of cookies.
Privacy Policy ·
Disclaimer