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
grandymaker [24]
3 years ago
9

Write the definition of a void function that takes as input two integer values, say n and m. The function returns the sum and av

erage of all the numbers between n and m (inclusive).
Computers and Technology
1 answer:
hodyreva [135]3 years ago
7 0

Answer:

void mn(int m, int n){

   int sum = 0;

int count = 0;

   if(m<n){

       for(int i = m;i<=n;i++){

           sum+=i;

       }

   }

   else{

       for(int i = n;i<=m;i++){

           sum+=i;

       }

   }

count = abs(m - n)+1;

   cout<<"Sum: "<<sum<<endl;

   cout<<"Average: "<<(float)sum/count;

}

Explanation:

This line defines the method

void mn(int m, int n){

This initializes sum and count to 0

   int sum = 0;

int count = 0;

This checks if m is less than n

   if(m<n){

This iterates from m to n and calculates the sum of numbers between this interval

<em>   for(int i = m;i<=n;i++){</em>

<em>            sum+=i;</em>

<em>        }</em>

<em>    }</em>

If otherwise,

   else{

This iterates from n to m and calculates the sum of numbers between this interval

<em>        for(int i = n;i<=m;i++){</em>

<em>            sum+=i;</em>

<em>        }</em>

<em>    }</em>

This calculates the range from m to n using absolute function

count = abs(m - n)+1;

This prints the calculated sum

   cout<<"Sum: "<<sum<<endl;

This calculates and prints the average

   cout<<"Average: "<<(float)sum/count;

}

<em>See attachment for complete program that includes the main (in c++)</em>

Download cpp
You might be interested in
Unlike when writing in a programming language, there are no set rules that must be followed when writing pseudocode. What do you
Elan Coil [88]

Answer:

Explanation:

Pseudocode may not have a set number of rules of guidelines but there are still some habits that should be followed. This includes having only one statement per line and add the END keyword to loops. Both of these rules/habits will drastically increase the readability of the pseudocode and allow you to know exactly where a certain loop starts and ends. Since loops can become difficult to read if they have a lot of code within them. Another good guideline to keep in mind is to simplify the code as much as possible do not add unnecessary pseudocode if it is not absolutely needed.

7 0
3 years ago
In Python, arrays are usually reserved for
Katen [24]
It would be the first one! Hope this helps have a great day
5 0
3 years ago
Sorting Records in a Form
Naya [18.7K]

Answer:

1. Open the form in the standard form view.

2. Put the cursor in the field to use for sorting.

3. Open the Home tab

4. In the Sort & Filter group, click ascending or descending

Explanation:

Took the test :)

7 0
3 years ago
What does it mean to use too much jargon in a slide presentation?(computer applications)
marin [14]
B.using too much jargon means you are using words that may be unfamiliar to the audience. <span>is the answer. jargon is</span><span> difficult words that others might not understand.</span>
8 0
3 years ago
Read 2 more answers
What is the definition of assiduous?
LuckyWell [14K]

Answer:

showing great care and perseverance.

6 0
3 years ago
Read 2 more answers
Other questions:
  • What does the dashed line in the beaker separating the two sides represent?______________________?
    13·2 answers
  • Which of the following is NOT true of input validation?
    7·1 answer
  • Who made the Apple company?
    9·2 answers
  • How can you download and install optional Windows updates?
    10·1 answer
  • In the state of Florida your first conviction for DUI can result in your vehicle being impounded for:
    14·2 answers
  • Which law was established to prevent law enforcement agencies from accessing communication through telephone and digital mediums
    8·2 answers
  • A device has an IP address of 10.1.10.186 and a subnet mask of 255.255.255.0. What is true about the network on which this devic
    9·1 answer
  • What do space stations, artificial organs, supersonic aircraft, and "high-tech”
    10·1 answer
  • Carlos is using the software development life cycle to create a new app. He has finished coding and is ready to see the output i
    12·2 answers
  • Hardware refers to programs and protocols used on a computer system.<br><br> True<br> False
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!