- A1
- BCompiler Error
- C10
- DGarbage value
int x = &y;int *x = y;int &x = y;int *x = &y;
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
In the following declaration
const int *p;
p can keep address of constant integer.
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: 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: B
Explanation: In C++, a pointer can be reassigned to point to a different memory location, while a reference always refers to the same object throughout its lifetime. Additionally, a reference must be initialized when it is declared, while a pointer can be declared without initialization.
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.