Solaris
Party Escort Bot
- Joined
- Feb 11, 2005
- Messages
- 10,318
- Reaction score
- 4
Hey guys,
I'm trying to write a C program to approximate sin x, function, using the Maclurin expansion.
Here is my code:
#include <stdio.h>
#include <stdlib.h>
double sin1(double x);
int main(void)
{
double x;
double answer;
printf("Sinx, x=...");
scanf("%lf", x);
answer = sin1(x);
printf("%1f", answer);
double sin1(double x)
{
double x3 = (x*x*x)/(3*2);
double x5 = (x*x*x*x*x)/(5*4*3*2);
double x7 = (x*x*x*x*x*x*x)/(7*6*5*4*3*2);
sin1 = x-x3+x5-x7;
printf("sin x = %lf", sin1;
return(sin1);
}
}
The first error message is for line 19,(4 from bottom), the line that says sin1= x-x3+x5-x7. Could anyone tell me whats wrong and correct it? I am very knew to C and need to finish this urgently
Thanks helplife2.net
I'm trying to write a C program to approximate sin x, function, using the Maclurin expansion.
Here is my code:
#include <stdio.h>
#include <stdlib.h>
double sin1(double x);
int main(void)
{
double x;
double answer;
printf("Sinx, x=...");
scanf("%lf", x);
answer = sin1(x);
printf("%1f", answer);
double sin1(double x)
{
double x3 = (x*x*x)/(3*2);
double x5 = (x*x*x*x*x)/(5*4*3*2);
double x7 = (x*x*x*x*x*x*x)/(7*6*5*4*3*2);
sin1 = x-x3+x5-x7;
printf("sin x = %lf", sin1;
return(sin1);
}
}
The first error message is for line 19,(4 from bottom), the line that says sin1= x-x3+x5-x7. Could anyone tell me whats wrong and correct it? I am very knew to C and need to finish this urgently
Thanks helplife2.net