Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   what does this error mean ? (http://www.go4expert.com/forums/error-mean-t5358/)

raurava 20Jul2007 13:38

what does this error mean ?
 
hello all ,
I am new to C programming and trying to learn by working some online tutorials.
I am working on a linux OS ( Ubuntu ) .

so the program is to calculate a table of sine values and I typed in the code pretty much the way it was show in the tutorial, the code is shown below:

Code:

                                /* Written: Winter 1995        */
#include < stdio.h>
#include < math.h>

void main()
{
    int    angle_degree;
    double angle_radian, pi, value;

                                        /* Print a header */
    printf ("\nCompute a table of the sine function\n\n");

                                        /* obtain pi once for all */
                                        /* or just use pi = M_PI, where
                                          M_PI is defined in math.h        */
    pi = 4.0*atan(1.0);
    printf ( " Value of PI = %f \n\n", pi );

    printf ( " angle    Sine \n" );

    angle_degree=0;                        /* initial angle value                  */
                                        /* scan over angle                  */

    while (  angle_degree <= 360 )        /* loop until angle_degree > 360 */
    {
      angle_radian = pi * angle_degree/180.0 ;
      value = sin(angle_radian);
      printf ( " %3d      %f \n ", angle_degree, value );

      angle_degree = angle_degree + 10; /* increment the loop index        */
    }
}

When I try to complile the program by typing

$ gcc program_name.c

I get the following error :

/tmp/cciKZE0g.o: In function `main':
sine.c:(.text+0x58): undefined reference to `sin'
collect2: ld returned 1 exit status


what does this mean ?? what should I do ? can any one help ?

thanks ,
raurava

DaWei 20Jul2007 15:05

Re: what does this error mean ?
 
Before you make a query

shabbir 20Jul2007 15:59

Re: what does this error mean ?
 
Have proper code blocks when you post code snippets in the posts.

DaWei 20Jul2007 19:15

Re: what does this error mean ?
 
In C, which you are using, sin takes a double as an argument, not a float. Use sinf for floats. In C++, the functions are overloaded, so will work. Refer to your documentation for the functions you use.


All times are GMT +5.5. The time now is 00:38.