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

Write a complete which Includes a function named odd_sum. The function is pa.-,s

ID: 3681226 • Letter: W

Question

Write a complete which Includes a function named odd_sum. The function is pa.-,se wo integer arguments, start and atop, and returns the sum of all integers between start and stop (including start and stop) except for those that are evenly divisible by 2. You can assume that start is less than or equal to stop. For example, odd sun (1, 5) returns 9 and odd_sum (10,13) returns 24 Your main function will get inputs, start and stop, from the user, call the function, and print out the answer. Include a design chart.

Explanation / Answer

#include <stdio.h>
int odd_sum(int start,int stop){
   int i=0,sum=0;
   for(i=start;i<=stop;i++){
       if(i%2==1)
           sum = sum + i;
   }
   return sum;
}
int main(void) {
   // your code goes here
   printf("%d ",odd_sum(1,5));
   printf("%d ",odd_sum(10,13));
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote