1
0
mirror of https://github.com/krislamo/knrc.git synced 2024-09-19 21:00:35 +00:00

Variables and arithmetic

This commit is contained in:
Kris Lamoureux 2021-11-03 00:37:32 -04:00
parent 3e078042a4
commit 9a193d84f1
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
2 changed files with 24 additions and 1 deletions

20
02-vars-and-math.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
/* 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;
}
}

View File

@ -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