- 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: 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: 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: B
Explanation: A pointer to a function in C is a pointer that stores the address of a function in memory. You can use this pointer to call the function directly, without having to refer to it by name.
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.