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:

#include<stdio.h>
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:

#include<stdio.h>
int main(){
    int a=100;
    unsigned int b=(unsigned)&b;
    printf("%u",b);
    return 0;
}

Address arithmetic in c:

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

#include<stdio.h>
int main(){
    int a;
    int b;
    printf("%d",&b-&a);
    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: &&, ||

Example:

#include<stdio.h>
int main(){
    int a=12,b;
    printf("%d",!&a);
    printf("%d",sizeof(&a));
    printf("%d",(int)&a);
    printf("%d",*&a);
    printf("%d  %d %d %d",&a&&&b,&a&&b,&a||&b,&a||b);
    return 0;

59 comments:

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

Unknown said...

0
4
-1081010724
12
1 0 1
1

Mukesh Kumar said...

Wow!
Very good explanation.
You are great.

lokesh said...

I got wonderful information from this blog. Thanks for sharing this post. it becomes easy to read and understand the information.
Data Science Course in Chennai
Data Science Courses in Bangalore
Data Science Course in coimbatore
Data Science Course in Hyderabad
Data Science Training in Bangalore
Best Data Science Courses in Bangalore
Data Science Institute in Bangalore
Data Science Training Institutes in Bangalore
AWS Training in Bangalore
DevOps Training in Bangalore

sasi said...

I really enjoyed this article. I need more information to learn so kindly update it.
Salesforce Training in Chennai
salesforce training in bangalore
Salesforce Course in bangalore
best salesforce training in bangalore
salesforce institute in bangalore
salesforce developer training in bangalore
Big Data Course in Coimbatore
Python Training in Bangalore
salesforce training in marathahalli
salesforce institutes in marathahalli

Vijayakash said...

Tally Course | Tally Institutei

I am glad that I have visited this blog. Really helpful, eagerly waiting for more updates.

Unknown said...

python course in coimbatore
java course in coimbatore
python training in coimbatore
java training in coimbatore
php course in coimbatore
php training in coimbatore
android course in coimbatore
android training in coimbatore
datascience course in coimbatore
datascience training in coimbatore
ethical hacking course in coimbatore
ethical hacking training in coimbatore
artificial intelligence course in coimbatore
artificial intelligence training in coimbatore
digital marketing course in coimbatore
digital marketing training in coimbatore
embedded system course in coimbatore
embeddedsystem training in coimbatore

Vijayakash said...

aws interview questions and answers for freshers

AWS Interview Questions and Answers for freshers and experienced to get your dream job in AWS! 101 AWS Interview Questions for Freshers, aws interview questions and answers for experienced

shree harini said...

python course in coimbatore
python training in coimbatore
java course in coimbatore
java training in coimbatore
android course in coimbatore
android training in coimbatore
php course in coimbatore
php training in coimbatore
digital marketing course in coimbatore
digital marketing training in coimbatore
software testing course in coimbatore
software testing training in coimbatore

Vijayakash said...

This is good site and nice point of view.I learnt lots of useful information.
digital marketing interview questions and answers for experienced
digital marketing executive interview questions and answers for freshers
pega testing interview questions
devops interview questions and answers for experienced pdf
aws interview questions and answers for freshers pdf
python interview questions and answers pdf
data science interview questions and answers for experienced

Vijayakash said...

Very useful article.
Nice article!


data science interview questions and answers for freshers
data scientist interview questions and answers
python interview questions and answers
digital marketing interview questions and answers
hadoop interview questions and answers
oracle dba interview questions
pega interview questions

prathyusha said...

Incredibly all around intriguing post. I was searching for such a data and completely appreciated inspecting this one. Continue posting. A commitment of gratefulness is all together for sharing.data science course in Hyderabad

Vijayakash said...

Nice blog was really feeling good to read it. Thanks for this information.


java interview questions and answers for experienced
java interview questions and answers
selenium interview questions and answers
digital marketing interview questions and answers for experienced
hadoop developer interview questions and answers for experienced
oracle interview questions and answers
python interview questions and answers pdf

360digitmg said...

You might comment on the order system of the blog. You should chat it's splendid. Your blog audit would swell up your visitors. I was very pleased to find this site.I wanted to thank you for this great read!!
Data Science Training in Hyderabad

prathyusha said...

Incredibly in general very intriguing post. I was looking for such an information and took pleasure in scrutinizing this one. Keep posting. An obligation of appreciation is all together for sharing.data analytics course in Hyderabad

360digitmg said...

Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.
Best Institute for Data Science in Hyderabad

prathyusha said...

Truly overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. Much obliged for sharing.data analytics course

Williams said...

It is really useful for getting more information.
software testing and its types
what's new in angular 5
what is python used for at google
ccna cloud
data science interview questions and answers

Mallela said...

Thanks for posting the best information and the blog is very informative.Data science course in Faridabad

guptha said...

Amazing post to keep updating more information.
statistics tutorial for data science
ethical hacking tutorials

Vijayakash said...

it was so good to read and useful

German Classes in Tambaram
German Classes in Anna Nagar
German Classes in Velachery
German Classes in T Nagar
German Classes in Porur
German Classes in OMR
German Classes in chennai

Huongkv said...

Mua vé máy bay tại Aivivu, tham khảo

vé máy bay đi Mỹ Vietnam Airline

vé máy bay hà nội sài gòn ngày mai

vé máy bay đi hà nội pacific airlines

vé máy bay đi đà lạt vietjet

vé bay từ mỹ về việt nam

taxi sân bay nội bài 180k

combo quy nhơn tháng 7/2021

Jasonsmith said...

Useful Information..!!! Best blog with effective information’s..!!
JAVA Training in Chennai
Selenium Training in Chennai
Python Training in Chennai
AWS Training in Chennai
Data Science Course in Chennai
DevOps Training in Chennai

Data Analytics Courses in Bangalore said...

I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
data science course fees in bangalore

Vijayakash said...

Great experience for me by reading this blog. Thank you for the wonderful article.

RPA Training in Tambaram
RPA Training in Anna Nagar
RPA Training in Velachery
RPA Training in T nagar
RPA training in Porur
RPA Training in OMR
RPA Training in Chennai

trainingcourses said...

This post is very simple to read and appreciate without leaving any details out. Great work!
best data science institute in hyderabad

Vijayakash said...

Nice blog was really feeling good to read it. Thanks for this information.

Spoken English Classes in Tambaram
Spoken English Classes in Anna Nagar
Spoken English Classes in Velachery
spoken english class in t nagar
Spoken English Classes in Porur
Spoken English Classes in OMR
Spoken English Classes in Chennai

EddieBrock said...

Finally I’m glad to check this blog because it’s a nice and informative blog.
Selenium Training in Chennai
Selenium Course in Bangalore
Selenium Training Online


trainingcourses said...

It's really nice and meaningful. it's a really cool blog.you have really helped lots of people who visit blogs and provide them useful information.

Best Data Science courses in Hyderabad

Mallela said...

Thanks for posting the best information and the blog is very important.data science institutes in hyderabad

trainingcourses said...

This post is very simple to read and appreciate without leaving any details out. Great work!
business analytics course

Deekshitha said...

Informative blog
data analytics courses in hyderabad

Deekshitha said...

Informative blog
data analytics courses in hyderabad

Deekshitha said...

Informative blog
data analytics courses in hyderabad

raj said...

Great post. keep sharing such a worthy information
Full stack developer course in chennai 
Full stack developer course in bangalore      

Akila said...

Great post. keep sharing such a worthy information
PHP Course in Chennai 
PHP Course in Bangalore   

Unknown said...

Great post. keep sharing such a worthy information

Big data training in chennai
Big Data Course in Chennai

360DigiTMG-Pune said...

Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
data scientist course in pune

Girl said...

Great post. keep sharing such a worthy information

Big data training in chennai
Big Data Course in Chennai

Unknown said...

Great post. keep sharing such a worthy information

Android Training in Chennai
Android Training in Bangalore

ramyapranauv said...

Fabulous Blog...good informative keep sharing
Digital Marketing Courses in Bangalore
Digital Marketing Training in Bangalore
Digital Marketing Training Institute in Chennai
Digital Marketing Institute in Chennai
Best Digital Marketing Course in
Chennai

ramyapranauv said...


Fabulous Blog...good informative keep sharing
Digital Marketing Course in Chennai
Digital Marketing Training in Chennai
Digital Marketing Institute in Bangalore
Best Digital Marketing Courses in Bangalore
Digital Marketing Training Institute in Bangalore

Samy said...

Great post. keep sharing such a worthy information
Digital Marketing Training Institute in Chennai
Digital Marketing Training in Bangalore

DataScienceBOX said...

Fantastic article I ought to say and thanks to the info. Instruction is absolutely a sticky topic. But remains one of the top issues of the time. I love your article and look forward to more.
Data Science Course in Bangalore

Akila said...

Great post. keep sharing such a worthy information
DevOps course in Chennai
DevOps Course in Bangalore

Akila said...

Great post. keep sharing such a worthy information
DevOps course in Chennai
DevOps Course in Bangalore

Data Science said...

I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
Data Science Course Syllabus

Pappu said...

Great share!
RPA Training Institute in Chennai
Rpa training in bangalore

ramyapranauv said...

Good Blog.. keep more updates
Data Science Course in Chennai
Data Science Training in Chennai
Data Science Certification in Chennai
Data Science Courses in Bangalore
Data Science Training in Bangalore

DataScienceEXPO said...

Thank you quite much for discussing this type of helpful informative article. Will certainly stored and reevaluate your Website.
Data Analytics Course in Bangalore

harikrishnan said...

Excellent post, it will be definitely helpful for many people. Keep posting more like this.
aws interview questions and answers
aws interview questions and answers for experienced
aws interview questions and answers for experienced pdf

DataCharge said...

Very wonderful informative article. I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks! .
Data Analytics training in Bangalore

DataBank said...

Nice to be seeing your site once again, it's been weeks for me. This article which ive been waited for so long. I need this guide to complete my mission inside the school, and it's same issue together along with your essay. Thanks, pleasant share.
Data Science training in Bangalore

Pallavi reddy said...

i am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
artificial intelligence training in chennai

Data Science Course in Varanasi - 360DigiTMG said...

Tremendous blog quite easy to grasp the subject since the content is very simple to understand. Obviously, this helps the participants to engage themselves in to the subject without much difficulty. Hope you further educate the readers in the same manner and keep sharing the content as always you do.

data science course in faridabad