Pointer Representation & Pointer Example Programs

pointer is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address

Accessing The Address:

& - Locate the Variable Address 
&variable 
ponter_variable = &variable; 

Pointer Representation


Definition:

Pointer variable Stores the another variable memory location(address).

Example program:

#include<stdio.h> 
#include<conio.h> 
void main() 

int i=10; 
printf("\nValue Of i :%d",i); 
printf("\nAddress Of i :%d",&i); 


Declaring Pointer Variables

* and varibale name 
pointer variable points to a variable of type data_type 

Syntax:

data_type *pt_name; 

Example:

int *p; 
float *x; 

Initialization Of Pointer Vaibale:

Syntax: 
pointer_vaibale = &variable; 

Example program : 1

#include<stdio.h> 
#include<conio.h> 
void main() 

int i=10; 
int *Ptr; 
clrscr(); 
Ptr=&i; 
printf("\nValue Of i :%d",i); 
printf("\nAddress Of i :%d",&i); 
printf("\nValue Of Ptr :%d",Ptr); 
printf("\nAddress Of Ptr :%d",&Ptr); 
printf("\nPtr's Pointer Value:%d",*Ptr); 
printf("\nPtr Equal to &i :%d",*(&i)); 


Example Program : 2

#include<stdio.h> 
#include<conio.h> 
void main() 

int i=10; 
int *Ptr; 
clrscr(); 
Ptr=&i; 
printf("\nValue Of i :%d",i); 
printf("\nAddress Of i :%d",&i); 
printf("\nValue Of Ptr :%d",Ptr); 
printf("\nAddress Of Ptr :%d",&Ptr); 
printf("\nPtr's Pointer Value:%d",*Ptr); 
printf("\nPtr Equal to &i :%d",*(&i)); 
printf("\n\nWe Can Chane Value Of i,Without Using i"); 
*Ptr=100; 
printf("\nValue Of i :%d",i); 
printf("\nAddress Of i :%d",&i); 
printf("\nPtr's Pointer Value:%d",*Ptr); 
getch(); 
}