Here, firstly ptr is initialized by the address of num, so it is not a NULL pointer, after that, we are assigning 0 to the ptr, and then it will become a NULL pointer.
#include <stdio.h>
int main(void) {
int num = 10;
int *ptr = #
//we can also check with 0 instesd of NULL
if(ptr == NULL)
printf("ptr: NULL\n");
else
printf("ptr: NOT NULL\n");
//assigning 0
ptr = 0;
if(ptr == NULL)
printf("ptr: NULL\n");
else
printf("ptr: NOT NULL\n");
return 0;
}
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer