Example program for pointer to pointer in C C++

Example program for pointer to pointer in C C++

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C के विभिन्न control statements को जानने के लिए देखें— Control statements in C

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

Example program for pointer to pointer in C

#include<stdio.h>
int main()
{
    int num=5;
    int *ptr1;
    ptr1=#
    int **ptr2;
    ptr2=&ptr1;
    printf("Value of num   = %d",num);
    printf("\nAddress of num = %p",&num);
    printf("\nValue of num   = %d",*ptr1);
    printf("\nAddress of num = %p",ptr1);
    printf("\nValue of num   = %d",**ptr2);
    printf("\nAddress of num = %p",*ptr2);
    return 0;
}

Example program for pointer to pointer in C++

#include<iostream>
using namespace std;
int main()
{
    int num=5;
    int *ptr1;
    ptr1=#
    int **ptr2;
    ptr2=&ptr1;
    cout<<"Value of num   = "<<num<<endl;
    cout<<"Address of num = "<<&num<<endl;
    cout<<"Value of num   = "<<*ptr1<<endl;
    cout<<"Address of num = "<<ptr1<<endl;
    cout<<"Value of num   = "<<**ptr2<<endl;
    cout<<"Address of num = "<<*ptr2<<endl;
    return 0;
}

Output of example program for pointer to pointer in C C++

Pointer to pointer program output in C CPP

Similar pointer example programs in C C++

  1. Declaration and assignment of pointer
  2. Sum of two numbers using pointer
  3. Average of three numbers using pointer
  4. Swapping two variables using pointer
  5. Pointer Arithmetic
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer