#include <stdio.h>
int cal_sum(int x, int sum)
{
if(x == sum) { /* break the recursion call when number is equal to max number */
return x;
}
return (x + cal_sum((x + 1), sum)); /* recursive call */
}
int main()
{
int x, max;
int sum = 0;
printf("Enter the number from where you wnat to start the sum : ");
scanf("%d",&x);
printf("Enter the max number upto where you wnat to perform the sum : ");
scanf("%d",&max);
sum = cal_sum(x, max);
printf("The sum(%d, %d) = %d\n", x, max, sum);
return 0;
}