Add ex1 for TP1
This commit is contained in:
parent
b1df23d81e
commit
94afcf9bc9
2 changed files with 40 additions and 0 deletions
7
programmation-c-cpp/tp1/Makefile
Normal file
7
programmation-c-cpp/tp1/Makefile
Normal file
|
@ -0,0 +1,7 @@
|
|||
all: convertisseur-devises
|
||||
|
||||
convertisseur-devises: convertisseur-devises.c
|
||||
gcc convertisseur-devises.c -o convertisseur-devises
|
||||
|
||||
clean:
|
||||
rm -f convertisseur-devises
|
33
programmation-c-cpp/tp1/convertisseur-devises.c
Normal file
33
programmation-c-cpp/tp1/convertisseur-devises.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* Convertisseur de devises */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TAUX_CHANGE 1.20
|
||||
|
||||
float calcul_dollar(float, float);
|
||||
|
||||
int main() {
|
||||
float euro, dollar;
|
||||
float taux_change = TAUX_CHANGE;
|
||||
|
||||
printf("Entrez un montant en € : ");
|
||||
fflush(stdin);
|
||||
scanf("%f", &euro);
|
||||
|
||||
dollar = calcul_dollar(euro, taux_change);
|
||||
|
||||
printf("Vous avez donc $%g\n", dollar);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
float calcul_dollar(float euro, float taux_change) {
|
||||
float dollar;
|
||||
|
||||
printf("Le taux de change €->$ est de %g.\n", taux_change);
|
||||
|
||||
dollar = euro * taux_change;
|
||||
|
||||
return dollar;
|
||||
}
|
Loading…
Reference in a new issue