Skip to content

Instantly share code, notes, and snippets.

@fahadcprogramming
Last active November 1, 2017 16:55
Show Gist options
  • Save fahadcprogramming/9b392cf6896da2c5e5aeb6016a2d7c04 to your computer and use it in GitHub Desktop.
Save fahadcprogramming/9b392cf6896da2c5e5aeb6016a2d7c04 to your computer and use it in GitHub Desktop.
Addition of pointers in c++ code
#include <iostream>
using namespace std;
int Sum(int *, int *);
float Sum1(int *,int *);
double Sum2(int *, int *);
int main()
{
int a,b;
cout<<"Enter 1st Value:";
cin>>a;
cout<<"Enter 2nd Value:";
cin>>b;
cout<<"...............ADDITION.............." <<endl <<endl;
cout<<"The integer sum of these numbers is:"<<Sum(&a,&b)<<endl;
cout<<"The float sum of these numbers is:"<<Sum1(&a,&b)<<endl;
cout<<"The double sum of these numbers is:"<<Sum2(&a,&b)<<endl;
cout<<endl <<endl;
cout<<endl <<endl;
return 0;
}
int Sum(int *x, int *y )
{
int sum;
sum=(*x + *y);
return sum;
}
float Sum1(int *x,int *y )
{
float sum;
sum=(*x + *y);
return sum;
}
double Sum2(int *x, int *y )
{
double sum;
sum=(*x + *y);
return sum;
}
@fahadcprogramming
Copy link
Author

pointer addition in c++

This code has been tested on codeblocks c++ compiler
find more explanation here program source c++ pointer addition
C++ source code to add two pointers find more examples at
C++ programs examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment