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
What does the computer receive when you press a key on a laptop keyboard?
Anit [1.1K]

Answer:

a computer receives signal

6 0
3 years ago
Adios brainly, you were sh.t sometimes, but you had your moments, wont be posting that much take my points away i d c
svlad2 [7]

you got a bad day today, bud?

3 0
3 years ago
Read 2 more answers
What are the task performed by window media player<br> ​
OLEGan [10]

Answer:

Windows Media Player (WMP) is a media player and media library application developed by Microsoft that is used for playing audio, video and viewing images on personal computers running the Microsoft Windows operating system, as well as on Pocket PC and Windows Mobile-based devices.

4 0
2 years ago
How did people find the first ever piece of tech?
kirill115 [55]
It's not how the found it, it's how they made it.
3 0
4 years ago
PowerPoint Online automatically saves your presentation to what Office Online application? OneDocument OneDrive OneNote OneWay
-BARSIC- [3]

Answer:

OneDrive

Explanation:

OneDrive is Microsoft cloud storage service. so it makes sense it would save it their :)

6 0
3 years ago
Read 2 more answers
Other questions:
  • In the windows firewall, any rules preceded by a __________ checkmark have not been enabled. black gray green red
    13·1 answer
  • Can't find the right year for this. (Attachment)
    6·1 answer
  • An employee who interacts with customers regarding the nature of their car problems, rather than actually working on the vehicle
    6·1 answer
  • 5 provisions of computer ethics
    6·1 answer
  • Describe how computer become <br> in the next 35 year
    5·1 answer
  • Pls help!!!!!!!!!!!!
    13·2 answers
  • Write a program that lets the user enter the total rainfall for each of 12 months into an array of doubles. The program should c
    13·1 answer
  • Suppose you are developing a data visualization application DataViz which calls some functions from a statistics library class S
    5·1 answer
  • The Painting Company has determined that for every 112 square feet of wall space:
    5·1 answer
  • Marly is using her smartphone to review a webpage she created. The formatting and alignment of webpage elements is incorrect. Wh
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!