Answer:
#include <iostream>
using namespace std;
void multipurpose(int &num1,int &num2,int &add,int &subt,int &multi,int &divi,int &modulo )
{
add=num1+num2;//adding two numbers...
subt=abs(num1-num2);//subtracting two numbers...
multi=num1*num2;//multiplying two numbers...
divi=num1/num2;//Finding quotient of two numbers...
modulo=num1%num2;//Finding modulo of two numbers...
}
void print(int add,int sub,int divi,int multi,int modulo) //function to print the values.
{
cout<<"The addition is "<<add<<endl<<"The subtraction is "<<sub<<endl
<<"The quotient is "<<divi<<endl<<"The multiplication is "<<multi<<endl
<<"The modulus is "<<modulo<<endl;
}
int main() {
int a,b,sum=0,mult=0,divi=0,sub=0,modulo=0;
cin>>a>>b;
multipurpose(a,b,sum,sub,mult,divi,modulo);
print(sum,sub,divi,mult,modulo);
return 0;
}
Enter the numbers
12 12
The addition is 24
The subtraction is 0
The quotient is 1
The multiplication is 144
The modulus is 0
Explanation:
I have created a function multipurpose that has a argument list of two numbers ,and variables for addition,subtraction,multiplication,Division,Modulus and these all are passed by reference.Since the function is of type void so it cannot return anything so the only way to store the result is by passing the variables to store the results by reference.
The other function print has the arguments of all the results here you can pass them by value or by reference because you only need to print the results.