- A1
- BCompiler Error
- C10
- DGarbage value
int x = &y;
int *x = y;
int &x = y;
int *x = &y;
In the following declaration
const int *p;
p can keep address of constant integer.
void func(int a) { } void main() { void (*fp)(int); fp=func; fp(1); }
Answer: A
Explanation: A pointer allows you to indirectly access the value of a variable by dereferencing the pointer with the * operator. A regular variable can be accessed directly with its identifier.
Answer: D
Explanation: The correct way to declare a pointer to an integer variable in C is to use the *
operator in the declaration, and assign the address of the variable using the &
operator.
Answer: A
Explanation: A NULL pointer in C is a pointer that points to a non-existent memory location. It is typically used to indicate that a pointer does not currently point to a valid object.
Answer: B
Explanation: Pointer arithmetic in C involves performing arithmetic operations on the memory addresses stored in pointers. For example, you can add or subtract an integer value from a pointer to move it to a different memory location. However, it is important to be careful with pointer arithmetic to avoid accessing invalid memory locations.
Answer: C
Explanation: A double pointer in C is a pointer that points to another pointer. It is typically used for dynamic memory allocation, where the first pointer points to a dynamically allocated memory block and the second pointer points to a specific location within that block.
Answer: C
Explanation: In C, a const pointer points to a const object, which means that the object it points to cannot be modified through the pointer. On the other hand, a pointer to a const can point to a non-const object, but it cannot be used to modify that object.