delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/05/23:38:37

From: Chris Ho-Stuart <hostuart AT sky DOT fit DOT qut DOT edu DOT au>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Why "c" is always zero??
Date: 6 Dec 1999 04:12:07 GMT
Organization: Queensland University of Technology, Australia
Lines: 30
Distribution: world
Message-ID: <82fd2n$17q$1@dove.qut.edu.au>
References: <82cko6$sfk$1 AT imsp026 DOT netvigator DOT com> <384A10E5 DOT E5BD0A30 AT sgi DOT net>
NNTP-Posting-Host: sky.fit.qut.edu.au
Mime-Version: 1.0
User-Agent: tin/pre-1.4-19990927 ("Nine While Nine") (UNIX) (SunOS/5.6 (sun4u))
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019