#include<stdio.h> void main( ) { int i = 3 ; printf("\nAddress of i = %u", &i ) ; printf("\nValue of i = %d", i ) ; printf("\nValue of i = %d", *( &i ) ) ; }
Output:
Address of i = 65524 Value of i = 3 Value of i = 3
Explanation :
Variable ‘i’ is declared of type integer in the program , now suppose the integer variable can have value 3 stored inside it and it has address 65524.
Suppose we want to access the address of the variable i then we can use ampersand operator to find the address of the variable.
Suppose we want to access the address of the variable i then we can use ampersand operator to find the address of the variable.
&i
and whenever we use ampersand and value at operator together then we will get actual value of the variable.
* (&i) = Value at (&i) = Value at (65535) = 3
Values of Variable and Address
Variable Expression | Meaning of the Variable | Value |
---|---|---|
&i
| Address of i | 65524 |
i | Value of variable i | 3 |
*( &i ) | Value of variable i | 3 |
No comments:
Post a Comment