Sum of Two Integers Using Pointers in C++

Pointers are very important in programming and dynamic memory allocation can't be performed without them. Pointer is also a variable and it used to store the memory address of the others variable.

Source Code

#include<iostream>
using namespace std;
int main ()
{
 int num1,num2,sum,*n1,*n2;
 cout<<"\t \t \t LEP Tutorials\n \n \n";
 cout<<"Enter Your First Number       : ";
 cin>>num1;
 cout<<endl;
 cout<<"Enter Your Second Number      : ";
 cin>>num2;
 n1 = &num1;
 n2 = &num2;
 sum = *n1 + *n2 ;
 cout<<endl;
 cout<<"The Sum Through Pointers is   : "<<sum<<endl;
}

Output of the Program

Sum of two integers using Pointers in C++

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment