i need to 'Write a program to print a table of ex using both a function and the exp() function from the math.h library, for x = 0 to 1 in steps of 0.1. The program should ask the user what value of n to use, being how many terms in the taylor expansion.' I get the error message 'expected expression before 'double' and dont know what to do!
Code:
#include <stdlib.h>
Code:
#include <stdio.h>
#include <math.h>
double taylor(double x, int n)
{
int i;
double sum = 1.0;
double term = 1.0;
for (i=1; i<=n; i++)
{
term = term * x / i;
sum = sum + term;
} return sum;
}
int main()
{
int a, n;
double b, c;
printf("type in an int: ");
scanf("%d", &n);
for (a=0; a<=10; a++)
{
b = a/10.0;
c = taylor(double b, int n);
}
printf("%f\t%f\n", b, c);
exit(0);
}