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
Write a single statement that assigns avg_sales with the average of num_sales1, num_sales2, and num_sales3.
sammy [17]

Answer:

Explanation:

try numpy:

import numpy as np

print(np.average([3, 4, 8]))

output:

5.0

3 0
3 years ago
Whose job is it to ensure that a group stays focused and on schedule?
topjm [15]

\text{Hello There!}

\text{The job of the facilitator is often to organize group activities.}

\bold{Therefore,\;your \;answer \;is\;going\;to\;be\;A, the\;facilitator.}

\huge\text{I hope this helped! :)}

\rule{250}{1.5}

5 0
3 years ago
What option is available on a Host A record to tell the system how long the record should remain in the database after it was cr
lapo4ka [179]

Answer:

Time to live.    

Explanation:

The Time to Live is used for the purpose of the expiration table in the rows dynamically.The Time to live is represented in the time limit to stay in the database the Time to live It is no longer possible to fetch the data that has passed its closing timeout value also it is not displayed in the store metrics.

The Time to live is available on the host in the log informing the system how long the record will stay in the database after it has been generated or last modified.

8 0
3 years ago
Consider the clipping of a line segment in two dimensions against a rectangular clipping window. Show that you require only the
Semmy [17]

Answer / Explanation:

Assuming we define the end points as ( x₁ , y₁) and (x₂ , y₂) and the rectangular window edge as ( Xmin ,Ymin and Xmax , Ymax)

The illustration of the above assumption is represented in the diagram below.

Now, suppose the line segment is between the points P₁ = ( x₁ , y₁) , and

P₂ = (x₂ , y₂).

We can then create a line recalling and using parametric form,

P(t) = ( 1 - t) P₁ + tP₂ , t ∈ {0 , 1 },

So, for the X axis, we have,

tₓ = P₁ₓ - x ÷ P₁ₓ - P₂ₓ

We need to note that at this point we need to know the minimum and maximum unclipped  values for parameter t from each dimension.

Therefore,

- ( tmin , tmax ) = ( 0,1) means unclipped line

-tmin > tmax means completely clipped out line

– Some other range means partially clipped out line.

6 0
3 years ago
This rlly isnt a question but give me some movies to watch or netflix movies/shows to watch
katovenus [111]
White chicks is a good one
5 0
3 years ago
Read 2 more answers
Other questions:
  • How would you say an hard drive works
    9·2 answers
  • Owning provides _________ flexibility but can lead to _________ costs in the long-term.
    7·2 answers
  • How can a professional association help you reach your career goals?
    5·1 answer
  • Writе thе dеclaration of a doublе pointеr namеd avеragе
    10·1 answer
  • Which table attributes would this code produce?
    15·1 answer
  • palindrome is a string that reads the same forwards as backwards. Using only a xed number of stacks, and a xed number of int and
    15·1 answer
  • Simple interest will always pay more interest than compound interest.
    14·1 answer
  • Phoebe is a Counselor who is trying to schedule a meeting with one of her patients. Which best describes an inappropriate locati
    10·2 answers
  • Sftp uses which mechanism to provide security for authentication and data transfer?
    7·1 answer
  • The _____ describes how data actually moves from an application on one computer to an application on another networked computer.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!