Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The code must be written in C. Write a program that computes the following summa

ID: 3811000 • Letter: T

Question

The code must be written in C.

Write a program that computes the following summation using a function. a + (a + 1) + ... + b = sigma^b_i = a i Write and implement the following function in your program: int computesum (int a, int b) The function computesum computes the sum of all the integers from a to b. You can compute the sum sigma^a - 1_i = 1 i and sigma^b_i = 1 i and use these to test your program. If your program is correct you should have sigma^a - 1_i = 1 i + sigma^b_i = a i = sigma^b_i = a i Sample execution of the program is given below Enter a and b 5 10 Sum from 5 to 10 is 45 Sum from 1 to 4 is 10 Sum from 1 to 10 is 55

Explanation / Answer

#include <stdio.h>
int computeSum(int a,int b);

int main()
{
int a,b;
printf("Enter a ");
scanf("%d", &a);
   printf("Enter b ");
scanf("%d", &b);
printf("Sum = %d",computeSum(a,b));
return 0;
}

int computeSum(int a,int b)
{

//using recursion to calculate the sum
if(n != 0 &&n>=a)
return n + addNumbers(n-1);
else
return n;
}