Skip to content

Commit 5006f14

Browse files
committed
include metric conversion
1 parent 1e5eee7 commit 5006f14

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

metric.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#define INCHES_PER_CENTIMETER 0.394
2+
#define CENTIMETERES_PER_INCH 1 / INCHES_PER_CENTIMETER
3+
4+
#define QUARTS_PER_LITER 1.057
5+
#define LITERS_PER_QUART 1 / QUARTS_PER_LITER
6+
7+
#define OUCES_PER_GRAM 0.035
8+
#define GRAMS_PER_OUNCE 1 / OUCES_PER_GRAM

prog.13.3.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* Program to illustrate the use of the #include statement
2+
* Note: This program assumes that definitions are
3+
* set up in a file called metric.h */
4+
5+
#include <stdio.h>
6+
#include "metric.h"
7+
8+
int main (void)
9+
{
10+
float liters, gallons;
11+
12+
printf ("*** Liters to Gallons ***'\n\n");
13+
printf ("Enter the number of liters: ");
14+
scanf ("%f", &liters);
15+
16+
gallons = liters * QUARTS_PER_LITER / 4.0;
17+
printf ("%g liters = %g gallons\n", liters, gallons);
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)