Solved

Floating-point modulo dividion in C

Posted on 1997-04-18
1
1,381 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

623 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