Hi guys
I have been trying to get this code running using GCC compiler in Fedora . I get an error while compiling which I am not able to resolve. Can someone help me out to fix this error?
Code:
//This program calculates the cosine of different angles.
#include<stdio.h>
#include<math.h>
#define PI 3.1416
#define MAX 180
main()
{
int angle;
float x;
float y;
angle=0;
printf("Angle Cos(angle)\n\n");
while(angle<=MAX)
{ x=(PI/MAX)*angle;
y=cos(x);
printf("%15d %13.4f\n",angle,y);
angle=angle+10;
}
}
[anishjp@anish C_programs]$ gcc cosine_function.c -o cosine_function
/tmp/ccITJ2Tu.o: In function `main':
cosine_function.c: (.text+0x37): undefined reference to `cos'
collect2: ld returned 1 exit status
Any help would be much appreciated!
Regards,
Anish