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]
3 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]3 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
Assume that ip has been declared to be a pointer to int and that result has been declared to be an array of 100 elements . Assum
Alenkasestr [34]

Answer:

The expression for this question can be given as:

Expression:

ip + (ip + 1) + (*ip + 2)

Explanation:

In the question, it is given that the ip variable that is a pointer type variable has been declared and initialized. This variable result has been declared to be an array of 100 elements and it is also defined that the ip variable is an element of the first half of the array. So the expression of the sum of the elements that point the ip that is ip + (ip + 1) + (*ip + 2). In this expression, ip is a pointer variable that's value is increased by 1 and 2. and all the value will be added in the ip.  

7 0
2 years ago
What best describes "broadband access"? a. broadband access is a specific term used to describe the delivery of one-way televisi
Alex_Xolod [135]

Answer:

c. broadband access describes several technical methods that enable users to connect to high speed networks

Explanation:

Broadband is a simply term used for a high speed connection to the internet. This kind of internet access allow users to do everything they want using the internet, such as downloading video or audio clips, listen to online radio, sending emails, and others, at a very fast rate. Broadband services transmit information 40 times faster than dial-up modem connection. There are several  different broadband access techniques such as ISDN , DSL , Cable , Satellite , and Wireless.

5 0
2 years ago
Write a method called swapPairs that switches the order of values in an ArrayList of strings in a pairwise fashion. Your method
arsen [322]

Answer:

  1. import java.util.ArrayList;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        ArrayList<String> strList =new ArrayList<String>();
  5.        strList.add("to");
  6.        strList.add("be");
  7.        strList.add("or");
  8.        strList.add("not");
  9.        strList.add("to");
  10.        strList.add("be");
  11.        strList.add("hamlet");
  12.        swapPairs(strList);
  13.        System.out.println(strList);
  14.    }
  15.    public static void swapPairs(ArrayList<String> list){
  16.        for(int i=0; i < list.size()-1; i+=2){
  17.            String temp = list.get(i);
  18.            list.set(i, list.get(i+1));
  19.            list.set(i+1, temp);
  20.        }
  21.    }
  22. }

Explanation:

Firstly, let's create a method swapPairs that take one ArrayList (Line 18). In the method, use a for-loop to traverse through each item in the ArrayList and swap the items between the current items at index-i and at index-i+1 (Line 19-22). The index-i is incremented by two in next loop and therefore the next swapping will proceed with third and fourth items and so forth.

In the main program, create a sample ArrayList (Line 5-12) and then test the method (Line 14) and print the output (Line 15). We shall get  [be, to, not, or, be, to, hamlet].

7 0
3 years ago
Which shortcut key aligns text to the center of the paige
borishaifa [10]

Answer:

ctrl e then ctrl r

Explanation:

i used google cause im a. gooooddddddddd

6 0
3 years ago
Is a process in which an attacker attempts to acquire information about your network and system by social means, such as talking
aleksandr82 [10.1K]
The answer would be software exploitation
4 0
3 years ago
Other questions:
  • If using the md5 hashing algorithm, what is the length to which each message is padded?
    11·1 answer
  • Consider the attack scenario given below:
    8·1 answer
  • Under which menu option of a word processing program does a star appear
    8·1 answer
  • A server would experience a __________ attack when a hacker compromises it to acquire information from it from a remote location
    13·1 answer
  • Write a program that displays the following menu:
    8·1 answer
  • What is sun and what does it do?
    12·2 answers
  • Any material that comes into contact with the body must be __________.
    6·1 answer
  • Explain what led to the invention of lasers
    7·1 answer
  • ______________ are used to store information that will be referenced and manipulated in a computer program. They label data with
    6·1 answer
  • what extension of nat allows several hundred workstations to access the internet with a single public internet address
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!