Knowee
Questions
Features
Study Tools

Find the sum of even numbers in the given range.Input Format:Accept two integer as inputOutput Format:Print the output as sum of even number available in the given rangeConstraints:1 <= INPUT <= 10^15Sample Input 1:10 20Sample Output 1:90Sample Input 2:30 33Sample Output 2:62

Question

Find the sum of even numbers in the given range.Input Format:Accept two integer as inputOutput Format:Print the output as sum of even number available in the given rangeConstraints:1 <= INPUT <= 10^15Sample Input 1:10 20Sample Output 1:90Sample Input 2:30 33Sample Output 2:62

🧐 Not the exact question you are looking for?Go ask a question

Solution

To find the sum of even numbers in the given range, follow these steps:

  1. Accept two integers as input, representing the range.
  2. Initialize a variable to store the sum of even numbers, let's call it "sum" and set it to 0.
  3. Iterate through each number in the given range.
  4. Check if the current number is even by using the modulo operator (%). If the number modulo 2 is equal to 0, it is even.
  5. If the current number is even, add it to the "sum" variable.
  6. After iterating through all the numbers in the range, print the value of "sum" as the output.

This problem has been solved

Similar Questions

Write a program to accept an integer N and print the sum of first N odd numbersInput Format:An integer range is given inputOutput Format:Print only calculated sum.Constraints:1 <= N <= 10^16 Sample Input 1:2Sample Output 1:4Sample Input 2:10Sample Output 2:100

Sum of EvenSend FeedbackProblem Statement:Write a program that takes a tuple as input and prints the sum of all the even numbers in the tuple.Input:A tuple containing integer elements.Output:The sum of all the even numbers in the tuple.Sample Input:(2, 3, 4, 6, 7)Sample Output:12

Write a program to print only the even numbers till given NInput FormatA single integer 'N'Output FormatDisplay all the even numbers between 0 and NSample Input10Sample Output0 2 4 6 8 10

Write a program to print the odd values in the given rangeInput FormatTwo space separated integers - 'start' and 'end'Output FormatDisplay all the odd numbers between 'start' and 'end'Sample Input10 20Sample Output11 13 15 17 19

Problem Statement:Write a  program to find the sum of numbers in the given range.Input Format:Given two integers start and end ranges separated by SPACE.Output Format:Print the sum in the given range.Constraints1<=start < end <= 1000000NOTE : The calculated sum value might exceed integer range.Sample Input 1:10 20Sample Output 1:165Sample Input 2:1 100Sample Output 2:5050

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.