Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1387
  • Last Modified:

Floating-point modulo dividion in C

I am using fmod() function to perform a floating-point remainder division as follows:

#include <stdio.h>
#include <math.h>

double fmod(double y, double z);

main()
{
        double x, mod, rem;

        x = 765.0;
        mod = 33.0;

        rem = fmod(x, mod);

        printf("The remainder is: %lf\n", rem);

}/* end main */

My question is: Why I am getting the following output:

queen(15)# cc test4.c
Undefined                       first referenced
 symbol                             in file
fmod                                test4.o
ld: fatal: Symbol referencing errors. No output written to a.out


Thanks for your help!
0
mkansal
Asked:
mkansal
1 Solution
 
marko020397Commented:
You should link library where this fmod function is. I think
it's in math library. Look for cc options how to link a
math library. It's been a long time I have compiled programs
in unix so I don't remember any more how to link libraries,
but it's everything written in documentation.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now