Write a function that takes two positive integers which define the values of a range. The function calculates and prints the ratio of the sum of even numbers to the sum of all the numbers in the range. input: Positive integers ‘start’ and ‘end’

profileJoJo2008

Write a function that takes two positive integers which define the values of a

range. The function calculates and prints the ratio of the sum of even numbers to

the sum of all the numbers in the range. 

input:

Positive integers ‘start’ and ‘end’

Output:

Ratio of sum of even numbers to the sum of all the numbers in the range defined by the numbers ‘start’ and ‘end’

Explaination:

Let’s say we have the values of ‘start’ and ‘end’ as 2 and 10 respectively. So, numbers between 2 and 10

are 2 , 3, 4 , 5 , 6 , 7, 8, 9 , 10

The sum of even numbesr in the given range is : 2 + 4 + 6 + 8 + 10 = 30

Total sum of all the numbers is 54

Ratio of the sum of even numbers to the sum of all the numbers in this range is 30/54 = 0.555 Hint: An even

number divided by 2 leaves a remainder 0.

    • 7 years ago
    • 5
    Answer(1)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      Programratio.docx