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
tester [92]
3 years ago
8

Write the definition of a function divide that takes four arguments and returns no value . The first two arguments are of type i

nt . The last two arguments arguments are pointers to int and are set by the function to the quotient and remainder of dividing the first argument by the second argument . The function does not return a value .The function can be used as follows:int numerator=42, denominator=5, quotient, remainder; divide(numerator,denominator,&quotient,&remainder); / quotient is now 8 / / remainder is now 2 /
Computers and Technology
1 answer:
Nastasia [14]3 years ago
8 0

Answer:

#include <iostream>

using namespace std;

void divide(int numerator, int denominator, int *quotient, int *remainder)

{

*quotient = (int)(numerator / denominator);

*remainder = numerator % denominator;

}

int main()

{

int num = 42, den = 5, quotient=0, remainder=0;

divide(num, den, &quotient, &remainder);

 

return 0;

}

Explanation:

The exercise is for "Call by pointers". This technique is particularly useful when a variable needs to be changed by a function. In our case, the quotient and the remainder. The '&' is passing by address. Since the function is calling a pointer. We need to pass an address. This way, the function will alter the value at the address.

To sum up, in case we hadn't used pointers here, the quotient and remainder that we set to '0' would have remained zero because the function would've made copies of them, altered the copies and then DELETED the copies. When we pass by pointer, the computer goes inside the memory and changes it at the address. No new copies are made. And the value of the variable is updated.

Thanks! :)

You might be interested in
The faster the clock speed, the more of these the processor can execute per second. what are they?
inna [77]
The more the Instructions

Also referred to as clock rate, clock speed is that speed the microprocessor executes each instruction. The CPU requires a number of cycles to execute an instruction. Thus, the faster the clock speed, the faster the CPU and the faster it can execute instructions in a second.



8 0
3 years ago
Read 2 more answers
What is the<br><br> stored program concept?
marin [14]

Answer:

 The stored program concept is defined as, in the architecture of computer where computer acts as internal store instruction and it is important because has high flexibility and user does not required to execute the instruction again and again. It is basically works on the principle of Von neumann architecture, as in which the instruction and the data are both same logically and can be used to store in the memory.

3 0
3 years ago
P6. In step 4 of the CSMA/CA protocol, a station that successfully transmits a frame begins the CSMA/CA protocol for a second fr
Karo-lina-s [1.5K]

Answer:

To avoid collision of transmitting frames.

Explanation:

CSMA/CA, carrier sense multiple access is a media access control protocol of wireless networks that allows for exclusive transmission of frames and avoidance of collision in the network. When a frame is not being sent, nodes listening for an idle channel gets their chance. It sends a request to send (RTS) message to the access point. If the request is granted, the access point sends a clear to send (CTS) message to the node, then the node can transmit its frame.

Many nodes on a wireless network are listening to transmit frames, when a frame is transmitting, the node has to wait for the access point to finish transmitting, so it sends a RTS message again to exclusively transmit a second frame.

8 0
4 years ago
¿Cuántos motores tiene el Toyota Prius y que características poseen?
ValentinkaMS [17]

Answer:

yo no se busca en gogle amiga

4 0
3 years ago
Supermarket managers who use scanners on the checkout counters to track inventory levels of their products are using a(n) ______
lidiya [134]
Operation Information System, because you are only collecting data on the amount of products leaving the store.
6 0
4 years ago
Other questions:
  • What type of engine is common on boats designed for shallow water?
    13·1 answer
  • Which of the following is a valid SQL statement? a. c.customer#, order#, orderdate, shipdate FROM customers c NATURAL JOIN order
    13·1 answer
  • You are asked to write an app to keep track of a relatively small music library. The app should load song information from a dat
    14·1 answer
  • Create a file with a 20 lines of text and name it "lines.txt". Write a program to read this a file "lines.txt" and write the tex
    12·1 answer
  • Computer science
    6·1 answer
  • Which is a good guideline to follow for adding animation to a presentation?. A. Use a different animation for each slide.. B. Us
    8·2 answers
  • C programming: loading a dictionary into a trie data structure. Why am I segfaulting?
    8·1 answer
  • The various protocols in use on the internet are said to operate in layers in which the protocol(s) at each layer solve one prob
    5·2 answers
  • Given an initialized String variable outfile, write a statement that declares a PrintWriter reference variable named output and
    12·1 answer
  • What G-Suite Apps integrate with Forms
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!