Entrance Exams
Govt. Exams
To modify a variable in the calling function, you must pass its address (pointer). Pass by value creates a copy and cannot modify the original.
p points to arr[0]. p+2 points to arr[2], and *(p+2) dereferences to the value at arr[2], which is 3.
malloc() and realloc() return uninitialized memory with garbage values. calloc() initializes all bytes to zero.
q is a pointer to pointer p. **q dereferences twice: first to get p, then to get the value x, which is 5.
A dangling pointer occurs when it points to memory that no longer exists, typically after free() or when a local variable goes out of scope.
Pointer arithmetic increments by the size of the data type. For int (4 bytes), ptr++ moves to the next integer, which is arr[1].
A void pointer cannot be directly dereferenced. It must be cast to the appropriate pointer type first.
ptr points to the first character of the string, so *ptr dereferences to 'H'. The %c format specifier prints a single character.
The & (address-of) operator returns the memory address of a variable.
The dereference operator (*) accesses the value at the address pointed to by p, which is the value 10.