diff --git a/02-vars-and-math.c b/02-vars-and-math.c new file mode 100644 index 0000000..bd7f578 --- /dev/null +++ b/02-vars-and-math.c @@ -0,0 +1,20 @@ +#include + +/* print Fahrenheit-Celsius table + for fahr = 0, 20, ..., 300 */ +int main() +{ + int fahr, celsius; + int lower, upper, step; + + lower = 0; + upper = 300; + step = 20; + + fahr = lower; + while (fahr <= upper) { + celsius = 5 * (fahr-32) / 9; + printf("%d\t%d\n", fahr, celsius); + fahr = fahr + step; + } +} diff --git a/Makefile b/Makefile index 268703a..89ef3b6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -all: hello +all: hello mathvars hello: 01-hello-world.c gcc -o ./bin/01-helloworld 01-hello-world.c + +mathvars: 02-vars-and-math.c + gcc -o ./bin/02-mathvars 02-vars-and-math.c