Explore
ProGrad Programs
About Us

Edit
Reply




Edit

Program to find the sum of numbers in a given range | FACE Prep

Published on 10 Mar 2020

Program to find the sum of numbers in a given range is discussed here. Given the starting and ending interval, the sum of all the numbers in that range will be displayed as output.


For example,

Input: 1 10

Output: 55

Explanation: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55


Algorithm to find the sum of numbers in a given range


  • Input the start and end numbers.
  • Initialize sum = 0.
  • Repeat from i = start to and continue until i = end.
  • sum = sum + i
  • Print "sum"


Program to find the sum of numbers in a given range is given below.


C
C++
Java
Python 3

Output
1
10
55


Recommended Programs







If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in