Hi.
I'm very new to the C programming language. I am using "The C Programming Language (2nd Edition)" by Kernighan and Ritchie with the Apple Xcode IDE. I am trying to complete Exercise 1-4 found on page 13 modified with float values instead of int values. My code is found first below and resulting output is found below that.
Code:
#include <stdio.h>
main()
{
float fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
celsius = lower;
while (celsius <= upper) {
fahr = ((celsius * 9.0) / 5.0) + 32.0;
printf("%6.2f\t%6.2f \n", celsius, fahr);
celsius = celsius + step;
}
return 0;
}
Code:
[Session started at 2005-12-08 17:14:28 -0500.]
0.00 32.00
20.00 68.00
40.00 104.00
60.00 140.00
80.00 176.00
100.00 212.00
120.00 248.00
140.00 284.00
160.00 320.00
180.00 356.00
200.00 392.00
220.00 428.00
240.00 464.00
260.00 500.00
280.00 536.00
300.00 572.00
KR has exited with status 0.
As you can see, the output values are float but are rounded to int values. My Build Results console gives me one warning - "warning: return type defaults to 'int'." Can someone help me locate the source of my problem.
Thanks a lot in advance!