In C, you can create a special variable that stores the address rather than the value. This variable is called a pointer. A pointer is used to allocate memory dynamically i.e. at runtime. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc.
Ex: int * ptr;
Here prt is pointer variable
int is type of variable.
Key points:
Ex:
Recursion:
Recursion is the process of repeating items in a self-similar way. If a program allows you to call a function inside the same function, then it is called a recursive call of the function. The C programming language supports recursion. But while using recursion, need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.
Ex:
Ex: int * ptr;
Here prt is pointer variable
int is type of variable.
Key points:
- Normal variable stores the value where as pointer variable stores the address of the variable.
- The content of the C pointer always be a whole number i.e. address.
- Always C pointer is initialized to null, i.e. int * ptr=null.
- the value of null pointer is 0.
- & symbol is used to get the address of the variable.
- * symbol is used to get the value of the variable that the pointer is pointing to .
- The size of the pointer is 2 bytes.
- Two pointers can be subtracted to know how many elements are available between these two pointers.
Ex:
Recursion:
Recursion is the process of repeating items in a self-similar way. If a program allows you to call a function inside the same function, then it is called a recursive call of the function. The C programming language supports recursion. But while using recursion, need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.
Ex: