Skip to content

Commit 94afd54

Browse files
author
websealevel
committed
introduit les constantes symboliques
1 parent 7428501 commit 94afd54

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

chapitre1/arithmetic.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,25 @@
22

33
/* affiche une table de conversion des degrés en Fahrenheit-Celsius*/
44

5+
#define LOWER 0 /*limite basse de la table*/
6+
#define UPPER 300 /*limite haute de la table*/
7+
#define STEP 20 /* taille du pas*/
8+
59
int main()
610
{
711
// Déclaration (placé avant toute instruction)
812
float fahrenheit;
913
float celsius;
10-
int lower;
11-
int upper;
12-
int step;
13-
14-
// Assignement
15-
lower = 0;
16-
upper = 300;
17-
step = 20;
1814

19-
fahrenheit = lower;
15+
fahrenheit = LOWER;
2016

2117
// Header, aligné avec le tableau.
22-
printf("%12s\t%12s\n","Fahrenheit", "Celsius");
18+
printf("%12s\t%12s\n", "Fahrenheit", "Celsius");
2319

24-
while (fahrenheit <= upper)
20+
while (fahrenheit <= UPPER)
2521
{
26-
celsius = (5.0/9.0) * (fahrenheit - 32);
22+
celsius = (5.0 / 9.0) * (fahrenheit - 32);
2723
printf("%12.0f\t%12.2f\n", fahrenheit, celsius);
28-
fahrenheit = fahrenheit + step;
24+
fahrenheit = fahrenheit + STEP;
2925
}
3026
}

0 commit comments

Comments
 (0)