1. Engineering
  2. Computer Science
  3. need help with my function i am trying to add...

Question: need help with my function i am trying to add...

Question details

Need help with my function. I am trying to add the variable 'sum' to the output of the function 'Terms'. I keep getting the error message "Too few arguments too function Term". So, there is something wrong with my function and how I am adding it to sum.

Please explain so I can learn more.

#include <stdio.h>

int Term( int i, int sum)
{

if (i% 2==1)
   {
   return((double)4/(2*i-1));
   }
else{
   return (-(double)4/(2*i-1));
   }
}


void main(void)
{
int n, sum, i;

printf("n?: ");
scanf("%d", &n);

sum = 0.0;

for (i=1; i<=n; i++)
   {
   sum= sum+Term(i);
   printf("%5d: %.14f\n", i, sum);
   printf(sum);
   }
  
  
  
}

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution