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
Write function modifyString(origString, charsToReplace, count) that takes as input a string origString, a string charsToReplace,
laila [671]

Answer:

The code of the above program is provided below. using Python

Explanation:

<u>Code in Python 3:- </u>

def modifyString(origString,charsToReplace,count):

# Make s1 as original string

s1=origString

# Make s2 as charsToReplace string in lowercase

s2=charsToReplace.lower()

# Make s3 as charsToReplace string in uppercase

s3=s2.upper()

# Initialize answer as an empty string

ans=''

# Iterate the string upto length times

for i in range(len(s1)):

# check for chars in the string and append to the answer

if (s1[i] in s2) or (s1[i] in s3):

ans=ans+count*s1[i]

else:

ans=ans+s1[i]

# return the final string

return ans

print(modifyString("Our cat is funny","aeiou",5))    

print(modifyString("Our cat is funny","zu",3))

8 0
3 years ago
What is the difference between a database schema and a database state?
Alexxx [7]

Answer:

A database schema or an intention gives a description of the database. This can be considered as a blueprint of a database, and gives a list of fields in the database with their data types. ... A database state provides the present state of the database and its data.

8 0
3 years ago
Hordes of surreptitiously infiltrated computers, linked and controlled remotely, also known as zombie networks are known as:
icang [17]
~Hello there! ^_^

Your answer: Hordes of surreptitiously infiltrated computers, linked and controlled remotely, also known as zombie networks are known as..?

Your answer: Hordes of surreptitiously infiltrated computers, linked and controlled remotely, also known as zombie networks are known as botnets.

Hope this helps~





3 0
4 years ago
____ a program means writing down in a prescribed manner the instructions for using the program, the way in which the program pe
Vlada [557]
The answer is d labeling
7 0
3 years ago
Which occupation requires certification by the state?
VARVARA [1.3K]
Interpreting I know of at least sign language the state is requiring you to be certified in order to have that occupation.
3 0
3 years ago
Read 2 more answers
Other questions:
  • What is print media?
    14·1 answer
  • Jackson builders is constructing new homes in the Parkway subdivision.The company needs the logic for an application that ncalls
    13·1 answer
  • Which command on the page layout ribbon enables a user to mark where a new page will begin on the printed copy?
    6·1 answer
  • What is some advice you would give someone who is just starting online learning 2 sentences
    8·1 answer
  • You csn access various sites on the www by using hyperlinks or by
    7·1 answer
  • Email, instant messaging and most web traffic go across the internet in the clear; that is, anyone who can capture that informat
    15·2 answers
  • A bank is experiencing a DOS attack against an application designed to handle 500IP-based sessions. In addition, the perimeter r
    11·1 answer
  • If your hood suddenly flies up you should turn on your hazard lights and continue driving. True or false?
    10·2 answers
  • I want to do is speed test to do i go to for my computer
    11·1 answer
  • To read encrypted data, the recipient must decipher it into a readable form. What is the term for this process?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!