# Sum of Integers in given range coderinme

#### Sum of Integers in given range coderinme

Sum of Integers in given range coderinme
Finding the sum of all numbers in a given range manually would be very hectic, frustrating as well as a time taking process. To make it simple Let us now write a program in C that reads two integers named start and end in the main program. It passes these two integers to a function sub program that uses for loop to find the sum of all the integers from start to end and returns the sum to the main program. The main program should print the sum.

What we are supposed to do here is very simple. Assuming that the start number is 5 and the end number is 8, then the required output is 5 + 6 + 7 + 8 = 26

``````#include<stdio.h>
int summ(int a,int b)
{
int sum=0;
for(; a <= b ; a++)
{
sum = sum + a;
}
return sum;
}
int main()
{
int start,end,sum;
printf("\nEnter the start number: ");
scanf("%d",&start);
printf("Enter the end number: ");
scanf("%d",&end);
sum = summ(start,end);
printf("\nThe sum of integers from %d to %d is: %d",start,end,sum);
getch();
return 0;
}
`````` 