taeyounkim LOG
pointer practice (decomposing fraction program) 본문
Career&Study/Coding Practice
pointer practice (decomposing fraction program)
taeyounkim 2021. 7. 7. 16:42728x90
#include <stdio.h>
void decompose();
int main(void)
{
long i;
double d;
decompose(3.141592, &i, &d);
printf("%ld\n", i);
printf("%lf", d);
}
void decompose(double x, long *int_part, double *frac_part)
{
*int_part = (long) x;
*frac_part = x - *int_part;
}
728x90
'Career&Study > Coding Practice' 카테고리의 다른 글
pointer practice 3 (function to swap numbers) (0) | 2021.07.08 |
---|---|
pointer practice 2 (program to find the largest and smallest elements in an array) (0) | 2021.07.07 |
Program to display "SEVEN SEGMENT DISPLAY" (0) | 2021.07.06 |
Guessing a Number game codes (0) | 2021.07.05 |
Game of Craps code, 그리고 stackoverflow.com (0) | 2021.07.02 |