sine function is not working

Hi everybody.. I want make graphic sine. When i compile.. everything is ok. But, when i got run..he didn't working.. Though exe file had made.. this is my code.. Thanks.

#include <stdio.h>
#include <math.h>
// We need to output stuff, and we need the sine function

int main()
{
// declarations
int x;
char y[80];

// setting entire array to spaces
for(x = 0; x < 79; x++)
y[x] = ' ';
y[79] = '\0';

// print 20 lines, for one period (2 pi radians)
for(x = 0; x < 20; x++)
{
y[39 + (int) (39 * sin(M_PI * (float) x / 10))] = '*';
printf("%s\n", y);
y[39 + (int) (39 * sin(M_PI * (float) x / 10))] = ' ';
}

// exit
return 0;
}
Last edited on
If you are using gcc. Did you link with the math library? You can do that by adding the flag -lm when linking.
Peter87..
i'm got it, Thanks..
Topic archived. No new replies allowed.