help for sinus equation

I got an error report.I stated it below.

#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[])
{
int value,upper_limit;
float x;
printf("enter the value of angle"); scanf("%d",&value);
printf("enter the upper limit"); scanf("%d",&upper_limit);

printf("The valuse of angle is %.3f",sin(value,upper_limit));// I get the report here

system("PAUSE");
return 0;
}

This is sin function

float sin(int x, int y)
{
int i;
double a=0,radyan=0.0;
float value=0;
radian=3.14*x/180;

for(i=0;i<=y;i++)
{
a=exponentiate(-1,i)*exponentiate(radian,2*i+1)/fakto(2*i+1);
value=value+a;
}
return value;
}
I stated it below.

No you didn't. And use the code tags please.
You should be getting a lot of errors. I see 4 right away.

1. sin() needs a prototype before main()
2. exponentiate() is not defined
3. fakto() is not defined
4. radyan should be radian
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[])
{
int value,upper_limit;
float x;
printf("enter the value of angle"); scanf("%d",&value);
printf("enter the upper limit"); scanf("%d",&upper_limit);

printf("The valuse of angle is %.3f",sin(value,upper_limit));// I get the report here

system("PAUSE");	
return 0;
}

twelfth line faulty

This is sin function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
float sin(int x, int y)
{
int i;
double a=0,radyan=0.0;
float value=0;
radian=3.14*x/180;

for(i=0;i<=y;i++)
{
a=exponentiate(-1,i)*exponentiate(radian,2*i+1)/fakto(2*i+1);
value=value+a;
}
return value;
}

You still didn't say exactly what error you are getting... you really make me cry... this should be obvious...

Yep, I feel a bit whiny today.
You should be getting a lot of errors. I see 4 right away.

1. sin() needs a prototype before main()
2. exponentiate() is not defined
3. fakto() is not defined
4. radyan should be radian


I call the functions from diffrent files

You still didn't say exactly what error you are getting... you really make me cry... this should be obvious...

Yep, I feel a bit whiny today.


Sorry i misunderstood you
These are the error reports;
1. in function main
2.too many arguments to functions sin
3.[build error] [main.0] error 1
Two things:

Put a function prototype for your sin function above your main.
Call your function sine - sin is already used by math.h, which might get included by one of your other headers.
AFAIK you can't overload a function in C.
There is already a sin function, that takes only 1 argument, defined in math.h (that get included somehow)
I know there is already a sin function but i want to this that way.
Thanks for your help.
AFAIK you can't overload a function in C.


Of course you can. The problem is that he didn't declare a prototype which is why his overload isn't known in the main function.
Last edited on
Actually, you can't. Standard C doesn't let you overload functions.
What? Aren't the math.h functions all overloaded for float, double and long double? O_o

Though I gotta admit I don't know all that much about C.
Last edited on
1
2
3
double sin(double x);
float sinf(float x);
long double sinl(long double x);
I love c++
Topic archived. No new replies allowed.