Saturday, 31 January 2015

Sum of two integers using Pointers in C++

Structure of Problem Requirements 

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 it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment