valor mod bajando por 1

votos
0
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void)
{   
int loonies, quarters ;
double amountdue, balanceowing, owing;

printf(Please enter the amount to be paid: $);
scanf(%lf, &amountdue);

loonies = amountdue / 1;
balanceowing = (amountdue - (int)amountdue);

quarters = (balanceowing / 0.25);
owing = ((int)(balanceowing*100) % 25);



printf(Loonies required: %d, balance owing $%.2lf\n, loonies, balanceowing);
printf(Quarters required: %d, balance owing $%.2lf, quarters , owing/100);
return 0;

}

Tengo que poner el valor 8,68 y obtener la salida

Please enter the amount to be paid: $8.68  
Loonies required: 8, balance owing $0.68  
Quarters required: 2, balance owing $0.18  

esta es la salida me estoy haciendo con mi solución

Please enter the amount to be paid: $8.68  

Loonies required: 8, balance owing $0.68  
Quarters required: 2, balance owing $0.17  

¿por qué es el valor devuelto por causa = 0,17? 68 mod 25 = 18

Es esta una especie de redondeo o truncamiento?

Publicado el 19/09/2018 a las 17:15
fuente por usuario
En otros idiomas...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more