You are currently viewing What is Pointers in C programming Language
Pointers in C programming

What is Pointers in C programming Language

Spread the love

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 ( * ).

pointer in C programming
Workings of pointer

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

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

Spread the love

Santosh Adhikari

Hello, it's me Santosh Adhikari, from Kathmandu, Nepal. I'm a student of Science and Technology. I love new challenges and want to explore more on Software Quality Assurance. I want to be a professional SQA. I'm also interested in Blogging, SEO activities.
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments