#include <math.h> double fmod(double y, double z);
fmod
determines the remainder when a real value y
is divided by
a real value z
to produce an integer i
. This function satisfies
these relationships:
result x y = i * z + x, |x| < |y|This function performs the same operation for
double
arguments as the
%
operator does for int
arguments.
fmod
returns the remainder of the division. If z
is 0, the value
returned is 0. Otherwise, the returned value has the same sign as y
and
is less than z
.
#include <math.h> #include <stdio.h> main() { float dollars; float leftovers; puts("Enter number of dollars"); scanf("%f", &dollars); leftovers = fmod(dollars, .05); printf("$ %.2f contains at least ", dollars); printf(" %.2f in penniesn", leftovers); }
modf
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.