Unit-V Pointers
Unit-V Pointers
Pointers
Contents
Pointers:
Introduction to Pointers
Declaring pointer variables
Programs using pointers
Introduction to Pointers
i Location name
3 Value at location
Output:
Address of i= 6356748
Value of i= 3
• A pointer is a constant or variable that contains an
address that can be used to access data.
• Pointers have many uses in C.
They provide a very efficient method of accessing data.
They provide an efficient technique for manipulating data in
arrays.
They can be used in functions as pass-by-address parameters.
They are the basis for dynamic allocations of memory.
Some more facts about pointers
• We can have pointer variables that point to all types of
variables – int, float, char, double.
• A pointer can also be used to point to another pointer
variable.
• A pointer can be used to point to a function
(Function pointers) .
• Pointers provide a handy way to access arrays and
strings.
• Pointers enable a programmer to return multiple data
items from a function.
Declaring a Pointer
ptrrad=&rad;
Enter the radius of the circle :2.0
ptrarea=&area;
return 0;
}
Programs for practice