Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Floating-point modulo dividion in C

Posted on 1997-04-18
1
Medium Priority
?
1,384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
marko020397 earned 100 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

670 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