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
Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string
nika2105 [10]

Answer:

The encoding algorithm looks for pairs of characters that appear in the string more than once and replaces each instance of that pair with a corresponding character that does not appear in the string. ... Byte pair encoding is an example of a lossy transformation because it discards some of the data in the original string.

Explanation:

hope it helps!!

6 0
2 years ago
How do you enter the command prompt on Chromebook
Step2247 [10]

1) Go through the standard Chrome OS login screen (you'll need to setup a network, etc) and get to the web browser. It's OK if you login as guest.

2) Press [ Ctrl ] [ Alt ] [ T ] to get the crosh shell.

3) Use the shell command to get the shell prompt.

3 0
2 years ago
With landscape photography, which depth of field do you normally want? A) Small B)Small to Medium C)Large D)With landscapes it d
RideAnS [48]
I am not 100% on this but i think you would want a Large depth of field. 
3 0
3 years ago
Read 2 more answers
What is a tag in an HTML document?
Llana [10]

Answer: HTML is considered as the Lingua franca of the net that is a simple mark up language used for the purpose of web publishing for creating text and images. This can be viewed by any of the member and can be used within any browser. There is no need of special software for creating HTML pages and moreover the learning of HTML is pretty easy.

Explanation: If you need more help go follow me at dr.darrien

- thank you

3 0
3 years ago
Read 2 more answers
What is the minimum amount of hard drive space required for a 64-bit Windows 10 installation?
BaLLatris [955]

The minimum requirements for a 64-bit Windows 10 installation are 2 GB of RAM and a minimum of 16 GB of space on the hard drive.

<em>Hope this helps :)</em>

7 0
1 year ago
Other questions:
  • DeShawn uses Google Ads. He wants to enable website call conversion tracking so he can see how his current ad campaign is drivin
    12·1 answer
  • Software that instructs the computer how to run applications and controls the display/keyboard is known as the
    14·1 answer
  • When you write a C# program that stores a value in a variable, you are using temporary storage; the value you store is lost when
    12·1 answer
  • Tom's Art Supplies used to sell art supplies through mail order catalogs, but the company's order takers often had difficulty de
    9·1 answer
  • I keep getting this error: postfix.cpp: In function ‘double RPN_evaluation(std::string)’: postfix.cpp:42:26: error: cannot conve
    7·1 answer
  • When referring to hard drives, access time is measured in
    11·1 answer
  • Explain one way in which programmers may get hired.
    9·1 answer
  • Abby has always dreamed of having her own ice cream shop. Now as a young entrepreneur she has decided to pursue her dream, but s
    13·1 answer
  • On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * rn, where n is the distance
    15·1 answer
  • write the files used on QBASIC (If u will answer right answer I will follow U and U will got 40 points)​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!