Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
oorrja
GitHub Repository: oorrja/learntosolveit
Path: blob/master/languages/cprogs/Ex_1.4_cel2fahr.c
1240 views
1
/***
2
*
3
* Temperature Conversion Program, Celsius to Fahrenheit!
4
*
5
* print Fahrenheit-Celsius table for fahr = 0,20 ... 300
6
*
7
***/
8
9
#include <stdio.h>
10
11
int main(void)
12
{
13
float fahr, celsius;
14
int lower, upper, step;
15
16
lower = 0;
17
upper = 300;
18
step = 20;
19
20
printf("C F\n\n");
21
celsius = lower;
22
while(celsius <= upper)
23
{
24
fahr = (9.0/5.0) * celsius + 32.0;
25
printf("%3.0f %6.1f\n", celsius, fahr);
26
celsius = celsius + step;
27
}
28
return 0;
29
}
30
31