140k views
3 votes
divide is a function that takes four arguments and returns no value . The first two arguments are of type int . The last two arguments arguments are pointers to int that 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 .x and y are two int variables that have been declared and initialized . q and r are two int variables that have been declared .Write a statement that sets the value of q to the quotient of x divided by y, and sets the value of r to the remainder of x divided by y, by calling divide

User Dereon
by
4.3k points

1 Answer

7 votes

Answer:

divide(x, y, x/y, x%y)

Step-by-step explanation:

According to the question, the function divide has four arguments and can be written as:

divide(x, y, q, r)

Going further, the question assigns the value of the quotient of x divided y to q i.e

q = x / y

Also, the question assigns the remainder of x divided by y to r. i.e

r = x % y.

where % is the modulus/remainder operator.

Replacing q and r with their values in the function divide(x, y, q, r) above, the resulting function becomes:

divide (x, y, x / y, x % y)

User Petrnohejl
by
4.3k points