Skip to content

Instantly share code, notes, and snippets.

@gregheo

gregheo/remainder.c

Created Jul 27, 2016
Embed
What would you like to do?
remainder()
#include <stdio.h>
#include <math.h>
int main(void) {
double const number = 8.0;
for (double i = number; i < number * 2 + 1; ++i) {
printf("remainder(%2.0f, %2.0f) = %2.0f\n", i, number, remainder(i, number));
}
return 0;
}
/* output:
remainder( 8, 8) = 0
remainder( 9, 8) = 1
remainder(10, 8) = 2
remainder(11, 8) = 3
remainder(12, 8) = -4
remainder(13, 8) = -3
remainder(14, 8) = -2
remainder(15, 8) = -1
remainder(16, 8) = 0
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment