/* */ Click to Join Live Class with Shankar sir Call 9798158723

Pointer in C ?


A variable that contains the address of another variable or address of a memory location is called a pointer. A pointer is also called a pointer variable. A pointer variable can store address of other variables.


Pointer declaration and definition

In C language we know that all the variables should be declared before they are used, pointer variables should be declared before they are used.


Here, we see how to declare pointer variable.
Syntax:-
data * identifier;

  • type can be any data type such as int, float, char etc.
  • *the asterisk( * ) in between type and identifier tell that the identifier is a pointer variables.
  • Identifier are name given to the pointer variable.

Steps to be followed while using pointers

  1. Declare a data variable Ex:- int a;
  2. Declare a pointer variable Ex:- int*p;
  3. Initialize a pointer variable Ex:- p=&a;
  4. Access data using pointer variable Ex:- printf("%d",*p);
Q) W.A.P to initialize pointer to variable
 #include<stdio.h>
 void main()
 { 
 int a =25,b=34,sum;
 int *pa, *pb;
 pa=&a; 
 pb=&b;
 sum=*pa+*pb;
 printf(“%d”,sum);
 getch();
 }