-
-
Save parzibyte/b70a34650b40d9c36ef3f4dff617970e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> // printf | |
#include <math.h> // modf | |
int main(void) { | |
double numero = 123.45; | |
printf("El número es %f\n", numero); | |
// En las siguientes almacenamos las partes separadas | |
double parteDecimal, parteEntera; | |
parteDecimal = modf(numero, &parteEntera); // mandar apuntador de parteEntera | |
// modf devuelve la parte decimal, y pone la parte entera en la variable cuya dirección mandamos | |
printf("Parte entera: %f. Parte decimal: %f\n", parteEntera, parteDecimal); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment