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
Digital rights include the right to
faltersainse [42]
D. Speak your ideas with respect on the internet .
7 0
2 years ago
B =(-21) (0) + (-50) ÷ (-5)​
Irina-Kira [14]

Answer:

B=10

Explanation:

(-21) x 0=0 and (-50)÷(-5)=10

0+10=10

8 0
3 years ago
50 points! ㅠㅠ does anyone speak korean or watch korean animes? 안녕 ㅋㅋ ㅇㅅㅇ How do people make animationsss.
aleksklad [387]

Answer:

Explanation Well depends on what type of animations your asking for but Anime is almost entirely drawn by hand but It also takes skill to create hand-drawn animation and experience to do it quickly. ... They're the ones who make all the individual drawings after the top-level directors come up with the storyboards and the middle-tier “key animators” draw the important frames in each scene it has a lot of process .

6 0
3 years ago
Read 2 more answers
Which of the following is another term for a subfolder?
LenKa [72]
Subdirectory

Have a great day! c:
5 0
3 years ago
What are several networks connected together using a router
elixir [45]

Answer:

local Area Network, Wide Local Area Network and Personal Area Network

8 0
3 years ago
Other questions:
  • Help me Please?!! I will put you as brainliest.<br>I hope I spelled that right.
    5·2 answers
  • The technology behind the Internet and E-mail dates back as far as 1969. What two software innovations helped the Internet becom
    14·1 answer
  • What is an example of a memo
    9·1 answer
  • Universal Containers (UC) has multi-level account hierarchies that represent departments within their major Accounts. Users are
    13·1 answer
  • By the 1990s, ______________ technology enabled one person operating a desktop computer to control most—or even all—of these fun
    8·2 answers
  • What type of software testing is generally used in Software Maintenance?
    11·1 answer
  • All the network nodes are connected to each other
    8·1 answer
  • Logan has developed an excellent presentation with interesting content. He received great feedback on the evaluation
    10·1 answer
  • Create a file name that to ensure the that the file is easy to find
    12·2 answers
  • How have productivity programs improved the professional lives of people? (check all that apply)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!