Someone could help me with this issue from my exercise list:
Make a program that receives a real number, find and show:
- a) the whole part of that number;
- b) the fractional part of that number;
- c) the rounding of that number.
I do not know how to calculate this, my teacher had to use modf , but it did not work, giving a web search I found the following code that when tested it ran perfectly, but I can not understand the logic that was used.
float numero,inteira,fracao,arred;
printf("Digite um numero real: ");
scanf("%f%*c",&numero);
printf("Parte Inteira : %d \n",(int) numero);
printf("Parte Decimal : %f", numero - ((int)numero));