mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +00:00
Variables and arithmetic
This commit is contained in:
parent
3e078042a4
commit
9a193d84f1
20
02-vars-and-math.c
Normal file
20
02-vars-and-math.c
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user