Address of a variable in c

Location in a memory where a variable stores its data or value is known as address of variable. To know address of any variable c has provided a special unary operator & which is known as deference operator or address operator. It operator is only used with variables not with the constant. For example:

int main(){
    int a=5;
    printf("Address of variable a is: %d",&a);
    return 0;

We cannot write: &&a, because:

&&a=& (&a) =& (address of variable a) =& (a constant number)

And we cannot use address operator with constant.

Important points about address of variables in c:

(1)Address of any variable in c is an unsigned integer. It cannot be a negative number. So in printf statement we should use %u instead of %d, to print the address of any variable.

%d: It is used to print signed decimal number.

%u: It is used to print unsigned decimal number.

Since, if the address of any variable will beyond the range of signed short int it will print a cyclic value.

(2)Address of any variable must be within the range 0000 to FFFF in hexadecimal number format or 0 to 65535 i.e. range of unsigned short int in c. To print the address of any variable in hexadecimal number format by printf function we should use %x or %X.

%x: To print a number in hexadecimal format using 0 to 9 and a, b, c, d, e, f.

%X: To print a number in hexadecimal format using 0 to 9 and A, B, C, D, E, F.

(3)A programmer cannot know at which address a variable will store the data. It is decided by compiler or operating system.

(4)Any two variables in c cannot have same physical address.

(5)Address of any variable reserve two bytes of memory spaces.

(6) Address of any variable in c is not integer type so to assign an address to a integral variable we have to type cast the address. For example:

int main(){
    int a=100;
    unsigned int b=(unsigned)&b;
    return 0;

Address arithmetic in c:

(1) We can subtract address of any two variables.  For example:

int main(){
    int a;
    int b;
    return 0;

(2)We cannot add, multiply, divide two addresses.

(3) we can add or subtract a integer number with address.

(3)Other operators which can be used with addresses are:

(a)Negation operator:!

(b)Size operator: sizeof

(c)Type casting operator: (Type)

(e) Deference operator: *

(f)Logical operator: &&, ||


int main(){
    int a=12,b;
    printf("%d  %d %d %d",&a&&&b,&a&&b,&a||&b,&a||b);
    return 0;


Anonymous said...

give d ans of above prog

Anonymous said...

plz giv the ans of above prog

Anonymous said...

mention the output

Anonymous said...

mention the output..

Anonymous said...

Pls mention the o/p for the abv pgm....thank u

Kanak Gupta said...

1 0 1

Unknown said...

Very good explanation.
You are great.

sandeep saxena said...

I appreciate you for this blog. More informative, thanks for sharing with us.
C C++ Training in Chennai
c++ course fees
best c c++ training in chennai
C Language Training in Chennai
JMeter Training in Chennai
Appium Training in Chennai
javascript training in chennai
core java training in chennai

velraj said...

The innovative thinking of you in this blog. This blog makes me very useful to learn.
Selenium Training in Chennai
best selenium training in chennai
selenium classes in chennai
best selenium training in chennai
Selenium training in Adyar
Selenium Training in Tnagar
Big data training in chennai
Hadoop training in chennai
Digital Marketing Course in Chennai
JAVA Training in Chennai

cynthiawilliams said...

Excellent info, I really appreciate your work. Continue sharing more with latest updates.
Ethical Hacking course in Chennai
Ethical Hacking Training Institute in Chennai
Hacking course in Chennai
ccna Training in Chennai
Salesforce course in Chennai
PHP Training in Chennai
Tally course in Chennai
Ethical Hacking course in OMR
Ethical Hacking course in Anna Nagar
Ethical Hacking course in Vadapalani

sultana said...

Wonderful blog with great piece of information. Regards to your effort. Keep sharing more such blogs. Looking forward to learn more from you.
AWS Training in Chennai
AWS Certification in Chennai
Best AWS Training in Chennai
Cloud Computing Training in Chennai
RPA Training in Chennai
Data Science Training in Chennai
AWS training in Guindy
AWS training in Vadapalani
AWS Training in Anna nagar
AWS Training in Velachery

Bala said...

Really superb post, I got a lot of things from your valuable post and Well do...
Pega Training in Chennai
Pega Training
Oracle Training in Chennai
Spark Training in Chennai
Oracle DBA Training in Chennai
Excel Training in Chennai
Embedded System Course Chennai
Tableau Training in Chennai
Linux Training in Chennai
Soft Skills Training in Chennai

Prakash said...

Good blog!!! It is more impressive... thanks for sharing with us...
Selenium Training in Chennai
Selenium Course in Chennai
selenium course
Selenium Training Institute in Chennai
Selenium training in Guindy
Selenium Training in Tambaram
Python Training in Chennai
Big data training in chennai
SEO training in chennai
JAVA Training in Chennai

high technologies solutions said...

Looking for the Genuine Experience Certificate with 100% Complete Verification So Contact Experienced Letter Solutions Consulting Firms Which Provide Experienced Letter with100 % Guaranteed. Contact Now- 9599119376. Or Visit Website-

Banu Ravi said...

Awesome blog with lots of information. It is really helpful for all.
AngularJS Training in Chennai
AngularJS course in Chennai
Angular 6 Training in Chennai
AngularJS Training in Velachery
AngularJS Training in T Nagar
AngularJS Training in Vadapalani