Malloc is the function that is used for dynamically allocating memory to the different variables. The malloc returns a memory pointer of void type (void *). The statement malloc(sizeof(0)) returns a valid integer pointer because sizeof(0) represents the size of memory taken up by the integer value of 0. The memory allocated by memory is not automatically cleaned up by the compiler after execution of the functions and should be cleaned up by the programmer using the free() function.
The memory leak refers to the uncleared memory mat builds up across me lifetime of the process. When it comes to a huge value me system stalls its execution due to me unavailability of the memory. The segmentation fault on the other hand refers to me condition when our program tries to access a memory […]
If n is the given number, then the expression (n & (n-1)) = 0 gives the logical output depicting if it is a power of 2 or not, if (n & (n-1) == 0) printf (“The given number is a power of 2”);