101,543 views
2 votes
2 votes
Which of the following shows how to correctly declare pointer variable x?

A. int x;
B. int &x;
C. ptr x;
D. int *x;

User Plonknimbuzz
by
2.8k points

1 Answer

1 vote
1 vote

Answer:

declaration of pointer variables are done using *

Step-by-step explanation:

* denotes the declared variable is a pointer which can hold address of another location. To get values of any address & is used. For example, we have an integer variable a to which holds a value 10. if you want to read the address of the variable a, use &a. To store this address in any other memory declare a pointer variable.

int a = 10;

int *loc_a;

loc_a = &a;

User Ahmad Raza
by
2.7k points