C C++ program to find sum of two numbers using pointer

C C++ program to find sum of two numbers using pointer

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

C Language में उपलब्ध Operators और इनके विभिन्न प्रकारो को जानने के लिए देखें—Operators in C

C-Language में Operator Precedence और Associativity Rule क्या होता है जानने के लिए देखें— Precedence and Associativity in C

C program to find sum of two numbers using pointer

#include<stdio.h>
int main()
{
    int n1,n2,*p1,*p2,sum;
    printf("Enter two numbers: ");
    scanf("%d%d",&n1,&n2);
    p1=&n1;
    p2=&n2;
    sum=*p1+*p2;
    printf("Sum = %d",sum);
    return 0;
}

C++ program to find sum of two numbers using pointer

#include<iostream>
using namespace std;
int main()
{
    int n1,n2,*p1,*p2,sum;
    cout<<"Enter two numbers: ";
    cin>>n1>>n2;
    p1=&n1;
    p2=&n2;
    sum=*p1+*p2;
    cout<<"Sum = "<<sum;
    return 0;
}

Output of C C++ program to find sum of two numbers using pointer

C C++ program to find sum of two numbers using pointer

Important pointer programs in C C++

  1. Declaration and assignment of pointer
  2. Pointer to 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