Address Operator

Address Operator

Address operator is the mechanism in C programming. It will give the address of the variable where it is saved.
We can call the address operator as pointer alternatively. Because the pointer is having the address of the variable. The sign ampersand (&) is used to notate the address operator.

The applications of address operator is two.

First One:

For passing the reference to the function in the function call.

Eg: Consider the following example.

#include<stdio.h>
Void display(int *);
Void main()
{
Int a=20;
Display(&a);
//Address of ‘a’ sending to function display
}
Void display(int *p)
{
Printf(“The value of p is %d”,*p);
}
Output:
The value of p is 20
In this example, we have sent the address of the variable ‘a’ to the pointer p. and then we are printing
the value(de-referenced value).

Second One

In pointers. When we are using pointers we have to assign the address of the variable to the
pointer . because the pointer is the variable which can hold the address of another variable.
Eg: Consider the following example.
#include<stdio.h>
Void main()
{
Int a=20;
Int *p=&a;
Printf(“The value of p is %d”,p);
Printf(“The de-referenced value of p is %d”,*p);
}
Output:
The value of p is 2234
The de-referenced value of p is 20
In this example, we have assigned the address of the variable ‘a’ to the pointer p. and then we are printing the value and de-referenced value.

En-Query

Your Name*
Subject*
Phone Number*
Email Address*

Message*