Write a program in C++ to add the given two numbers using pointers.
1
Expert's answer
2020-11-20T10:11:07-0500
#include <iostream>
using namespace std;
int main()
{
int f,s,*p,*q,sum;
cout<<"Enter two integers to add\n";
cin>>f>>s;
p= &f;
q=&s;
sum= *p + *q;
cout<<"Sum of two numbers = "<< sum;
return 0;
}
Comments
Leave a comment