If

int main()
{
int a=1;
int *p;
how do the following statements differ
1) p=&a;

2) *p=&a;

3) p=a;

4) printf("%d",p);

5) printf("%d",*p);

and what does int **a mean

1) p points to a

2) the address of a is stored where p is pointing
3) p points to memory address 1
4) prints the address stored in p
5) prints the integer pointed to by p

Hello Ray :)

(Sorry if i have a bad English)

- int a = 1 : You declared an integer variable, (imagine that is a box that contain the value 1 : [1].

-int *p : You declared a pointer of integer . When we declare a pointer we need to put * before the variable . But * have an other meaning, when we use the pointers :

Imgine that p is an arrow that indicate integer boxes ->[int ?]. p will contain the address of the box, and *p allows us to see what's in the box .

1] Imagine that we give to "p" the address of "a", than the pointer p "->" will move and stuck to the box "a" like this : ->[ 1] "

2]we put into the box that was pointed by "p ->[?int]" the location of a . ( useless :) )

3] p will point to another memory slot, and we give to him an other box [] (in these case it will change nothing :) : p will point the same box "a" )

And like Steve said :

4] prints the address stored in p
5] prints the integer pointed to by p

1) p=&a; - This statement assigns the memory address of variable 'a' to the pointer variable 'p'. It means that 'p' is now pointing to the memory location where 'a' is stored.

2) *p=&a; - This statement is incorrect. It tries to assign the memory address of 'a' to the value of '*p', which is not allowed. '*p' is used to access the value stored at the memory address pointed to by 'p', not to assign a new value.

3) p=a; - This statement is also incorrect. It tries to assign the value of 'a' directly to the pointer variable 'p', which is not allowed. 'p' can only store memory addresses, not values.

4) printf("%d",p); - This statement prints the value of the pointer variable 'p' itself, which is the address of 'a', by using '%d' format specifier. However, using '%d' to print a pointer value is not accurate and leads to undefined behavior. The correct way to print a pointer is by using '%p' format specifier.

5) printf("%d",*p); - This statement prints the value stored at the memory address pointed to by 'p', which is the value of 'a', by dereferencing the pointer variable 'p' using '*' operator.

As for 'int **a', it is a declaration of a pointer to a pointer to an integer. It means that 'a' is a pointer that can store the memory address of another pointer that is pointing to an integer. This is commonly used in situations where you need to work with a pointer to a dynamically allocated array or a multi-dimensional array.