Answer:
#include <iostream>
#include <stdio.h>
using namespace std;
// create function called abDifference
void update(int *a,int *b) {
int r = *a;
#include <iostream>
#include <stdio.h>
using namespace std;
// create function called abDifference
void update(int *a,int *b) {
int r = *a;
*a = *a+*b;
*b = r-*b;
if(*b < 0)*b *= -1;
}
int main() {
int num1, num2;
cout<<"enter two ints"<<endl;
int *pa = &num1, *pb = &num2;
scanf("%d %d", &num1, &num2);
update(pa, pb);
cout<<num1<<endl;
cout<<num2<<endl;
return 0;
}
Explanation:
The function update does two things:
- 1. It evaluates the sum of the two arguments passed to it
- 2. It evaluates the absolute difference of the two ints passed as an argument
In the main method, the user is prompted to enter two ints. The method update() is called and passed the two ints. It prints the sum as num1 and the abs difference as num2