Solved

Floating-point modulo dividion in C

Posted on 1997-04-18
1
1,362 Views
Last Modified: 2008-07-03
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
Comment
Question by:mkansal
1 Comment
 
LVL 4

Accepted Solution

by:
marko020397 earned 50 total points
ID: 1249968
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now