Table of Contents
What is pointer in C programming?
A Pointers in C programming is a variable which is used to store the address of other variables. Unlike any other variables that holds certain types of data in the same way pointer holds the address of a variable. Pointer can be of type char, int, function, array or any other pointer. Pointer in C programming is very popular concept.
In C programming Language pointer is defined by using asterisk symbol ( * ).

Valid pointer declaration example
int *ip; //pointer to integer type double *dp; // pointer to a double type char *ch //pointer to character type float *fp; //pointer to a float
Consider the following example program to define a pointer which stores the address of integer data type.
int n = 50;
int* ptr = &n; //Variable ptr type of pointer is pointing to the address of integer type of variable n
Benefits of using Pointers in C programming
- Allocation of memory is done dynamically
- Used by arrays, functions and Structure to reduce complexity.
- Returns multiple values from a function
- Pointer reduces the code and improves the performance of program
The only difference between pointers of different data types is the data type of the variable or constant that the pointer points to.
A simple example to C program in pointer
#include <stdio.h>
int main(){
//variable declaration
int number = 20;
//pointer variable declaration
int *ptr;
//Assigning the address of number variable to ptr
ptr = &number;
printf(" The address of number variable is: %ptr", ptr);
return 0;
}
C program to find factorial of user given number
https://studywholenight.com/c-program-to-find-factorial/
NULL pointer in C programming
NULL pointer is the type of pointer which is not assigned to any value but NULL is known as the NULL pointer. This is done during the variable declaration. A pointer which is assigned to NULL is called NULL pointer.
C program to calculate factorial of number using pointer
#include <stdio.h>
int main () {
int n, *p, f=1, i;
printf("Enter a number to calculated factorial");
scanf("%d", &n);
p= &f;
for(i=1; i<=n; i++){
*p = (*p) * i;
}
printf("Factorial of %d is: %d", n, f);
return 0;
}
Documentation of C programming