1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
blondinia [14]
4 years ago
14

Define a void function that calculates the sum (+), difference (-), product (*), quotient (/), and modulus (%) of two integer nu

mbers that would be passed through parameter list. The function returns the results back to the caller (main) through reference parameters. Define another function that simply displays the result.
Computers and Technology
1 answer:
BabaBlast [244]4 years ago
7 0

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.

You might be interested in
A quick boot allows you to do what?
WITCHER [35]
Access the BIOS setup
6 0
3 years ago
Read 2 more answers
write a function named list_total that accepts a list as an argument (assume the list contains integers) and returns the cumulat
lutik1710 [3]

Answer:

def listSum(mylist):

  sum =0

  for item in range(0,len(mylist)):

      sum=sum+mylist[item]

  print(sum)

Explanation:

Using the Python programming language, I defined a function as listSum that accepts a list as a parameter and returns the sum of the elements in the list.

The most important logic here is defining the range of elements in the list not to exceed the length of the list using the len function. Then using a for statement, we loop through each element and add them up to a sum variable initially assigned the value of 0.

3 0
3 years ago
What is the name for unwanted software that installs when you click some links?
Rudik [331]
Malware you're welcome 
8 0
4 years ago
Read 2 more answers
Care sunt avantajele fișierelor de tip ".pdf" ?
Alex787 [66]

Answer:

english i speak .

Explanation:

7 0
3 years ago
Read 2 more answers
True or false, cloud storage does not require internet access?
Dmitry_Shevchenko [17]
False, the storage is being accessed from the cloud which can only be accessed through an internet connection.
3 0
4 years ago
Other questions:
  • The         provides access to the Internet; may also be internal
    5·1 answer
  • ​​most code division multiple access (cdma) networks conform to ____________ , created by the telecommunications industry associ
    10·1 answer
  • The best-known communications protocol is probably smtp, which regulates internet data transport. _________________________
    6·1 answer
  • Print a countdown from n to 1 The function below takes one parameter: an integer (begin). Complete the function so that it print
    8·1 answer
  • Increasing your margins will increase the amount of space you have to type text on your document. Please select the best answer
    10·1 answer
  • What is the maximum duration of daily Scrum meetings?
    13·1 answer
  • How can users open a shared worksheet if they do not have Excel installed on a computer? visit Microsoft’s website use Office365
    6·1 answer
  • Solving Systems of Equations by Substitution <br> pdf
    11·1 answer
  • Why are Quick Parts useful in an Outlook message?
    5·1 answer
  • Which item can you add using the tag?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!