Skip to content

Instantly share code, notes, and snippets.

@atpons
Created July 3, 2017 15:04
Show Gist options
  • Save atpons/3d7385f19d0390547282e951ebb09c44 to your computer and use it in GitHub Desktop.
Save atpons/3d7385f19d0390547282e951ebb09c44 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void intfrac(double input, int *ipart, double *dpart) {
*ipart = (int)input;
*dpart = (double)input - *ipart;
}
int main() {
int *ipart = 0, i;
double *dpart = 0, d, input;
ipart = &i;
dpart = &d;
printf("> ");
scanf("%lf", &input);
intfrac(input, ipart, dpart);
printf("%lf = %d + %lf\n", input, *ipart, *dpart);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment