Pointer arithmetic example programs in C C++

Pointer arithmetic example programs in C C++

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

C Language में Pointer to Pointer क्या होता है जानने के लिए देखें— Pointer to pointer in C

C Language में उपलब्ध विभिन्न प्रकार के Pointers और उनके उपयोग को जानने के लिए देखें—Types of Pointer in C

Incrementing pointer in C example program

#include<stdio.h>
int main()
{
    int num, *ptr;
    ptr=#
    printf("value of ptr = %u\n",ptr);
    ptr=ptr+1;
    printf("value of ptr = %u\n",ptr);
    ptr=ptr+1;
    printf("value of ptr = %u\n",ptr);
    return 0;
}

Incrementing pointer in C++ example program

#include<iostream>
using namespace std;
int main()
{
    int num, *ptr;
    ptr=#
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr+1;
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr+1;
    cout<<"value of ptr = "<<ptr<<endl;
    return 0;
}

Output of incrementing pointer in C C++ example program

Pointer Arithmetic Incrementing Programs in C C++

Decrementing pointer in C example program

#include<stdio.h>
int main()
{
    int num, *ptr;
    ptr=#
    printf("value of ptr = %u\n",ptr);
    ptr=ptr-1;
    printf("value of ptr = %u\n",ptr);
    ptr=ptr-1;
    printf("value of ptr = %u\n",ptr);
    return 0;
}

Decrementing pointer in C++ example program

#include<iostream>
using namespace std;
int main()
{
    int num, *ptr;
    ptr=#
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr-1;
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr-1;
    cout<<"value of ptr = "<<ptr<<endl;
    return 0;
}

Output of decrementing pointer in C C++ example program

Pointer Arithmetic Decrementing Programs in C C++

Related pointer programs in C C++

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

Published by

admin

I am a computer teacher, programmer and web developer