An implementation of exercise 1-15 that I spent far too long banging my head against over an issue that turned out to be me having flipped 5 and 9 in my math.
This commit is contained in:
parent
73d3fe21ac
commit
4ddc868da3
2 changed files with 17 additions and 1 deletions
16
KNR C/ex1_15.c
Normal file
16
KNR C/ex1_15.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
//A program for converting from C to F, using a function!
|
||||
float convCelsius(int fh){
|
||||
return ((fh) - 32) * (5.0 / 9.0);
|
||||
}
|
||||
|
||||
int main(){
|
||||
printf("%6s, %6s\n", "DEG F", "DEG C");
|
||||
for(int cFH = -200; cFH <= 400; cFH = (cFH + 10)){
|
||||
printf("%6.0d | %6.2f\n", cFH, convCelsius(cFH));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue