DEV/DEV1.1/TP04:Types/monnaie.c

31 lines
524 B
C
Raw Permalink Normal View History

2022-09-27 16:03:19 +02:00
#include <stdio.h>
int main(void) {
float r;
int p1;
int p2;
int p3;
float ar;
float p;
p=5.49;
p1=0;
p2=0;
p3=0;
ar=0;
r=0;
printf("Veuillez saisir la monnaie donner par le client.\n");
scanf("%f",&r);
ar=r-p;
while (ar>=2){
ar=ar-2;
p1+=1;
} while (ar>=0.20){
ar=ar-0.20;
p2+=1;
} while (ar>=0.01){
ar=ar-0.01;
p3+=1;
}
printf("Pour rendre la monnaie, il faudra %d pieces de 2euros, %d pieces de 20centimes et %d pieces de 1centime.\n",p1,p2,p3);
return 0;
}