Hands On No. 10 : To calculate the sum of all numbers between two given numbers
Resources
Source Code
fun main() {
val start = 15
val end = 25
val sum = calculateSum(start, end)
println("Sum of numbers between $start and $end: $sum")
}
fun calculateSum(start: Int, end: Int): Int {
var sum = 0
for (num in start..end) {
sum += num
}
return sum
}