Initial commit for KNR C exercises
This commit is contained in:
commit
67483eaceb
4 changed files with 32 additions and 0 deletions
BIN
KNR C/a.out
Executable file
BIN
KNR C/a.out
Executable file
Binary file not shown.
25
KNR C/ex1_1-tempconverter.c
Normal file
25
KNR C/ex1_1-tempconverter.c
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* print farenheit-celsius table
|
||||||
|
* for fahr = 0, 20, ..., 300 */
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
float fahr, celsius;
|
||||||
|
float lower, upper, step;
|
||||||
|
|
||||||
|
lower = 0; /* lower bound of temp scale*/
|
||||||
|
upper = 300; /* upper bound of temp scale*/
|
||||||
|
step = 20; /* step size between calculated conversions*/
|
||||||
|
|
||||||
|
fahr = lower;
|
||||||
|
while (fahr <= upper)
|
||||||
|
{
|
||||||
|
celsius = (5.0/9.0) * (fahr-32);
|
||||||
|
printf("%3.0f\t%6.1f\n", fahr, celsius);
|
||||||
|
fahr = fahr + step;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
7
KNR C/hello_world.c
Normal file
7
KNR C/hello_world.c
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
printf("hello, world\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
KNR C/hello_world.out
Executable file
BIN
KNR C/hello_world.out
Executable file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue