Mail Archives: djgpp/1999/12/05/23:38:37
John & Susie <jdk AT sgi DOT net> wrote:
>> Jason Yip wrote:
>>
>> Can anyone tells me why the value of "c" is always equal to zero??
>> How can I correct this?
>> Thanks a lot!!
>>
>> #include <stdio.h>
> <---- <float.h> is not declared.
Nor should it be declared...
>> float ftc(n) <---- you dont use the passed value 'n' in your function -
>> int n; <-----but you declare it old style here? (the address
> where it would be stored happened to be
> zero or
> your compiler automagicly set it to 0)?
> Your compiler
> should warn you here - dump this.
>> {
>> float c, f; int i; <---- f = 0 (dont count on it, could be anything)
>> for (i=0;i<=n;i++){ <---- 'f' is not modified
>> c=5/9*(f-32); <---- c = 5/9*(0-32) should be about -17.7777
Nope. there is no reason for f to be zero, but the above WILL be
zero, because 5 / 9 == 0
Cheers -- Chris
- Raw text -