Message-ID: <003101bf3eef$da619f80$0100a8c0@pcpablo> From: "Pablo M. Dotro" To: References: <82cko6$sfk$1 AT imsp026 DOT netvigator DOT com> Subject: Re: Why "c" is always zero?? Date: Sun, 5 Dec 1999 04:10:43 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002E_01BF3ED6.B2B086E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Reply-To: djgpp AT delorie DOT com This is a multi-part message in MIME format. ------=_NextPart_000_002E_01BF3ED6.B2B086E0 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi there! try changing 5/9 to 5.0/9.0 The compiler may be interpreting it as a n integer operation, and as = such, it will truncate de decimals, effectively doing 0 * (f-32). Hope this helps! Pablo M. Dotro pyd AT sion DOT com pdotro AT USSEnterprise DOT com pdotro AT labs DOT df DOT uba DOT ar ICQ#: 18144918 http://www.usuarios.sion.com/abismo ----- BEGIN GEEK CODE BLOCK ----- Version 3.12 GCS/S/IT/CM d- s: a23 c++$ UL P+ E W++ N++ o K- w O? M V? PS PE- Y+ PGP>+ t++ 5+ X+ R+>+++ tv b++ DI? D++ G++ e h! r- y+ -----END GEEK CODE BLOCK ----- (para decodificar el bloque, visite www.geekcode.com) ----- Original Message -----=20 From: Jason Yip=20 Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com=20 Sent: Sunday, December 05, 1999 12:03 AM Subject: Why "c" is always zero?? Can anyone tells me why the value of "c" is always equal to zero?? How can I correct this? Thanks a lot!! #include float ftc(n) int n; { float c, f; int i; for (i=3D0;i<=3Dn;i++){ c=3D5/9*(f-32); } return c; } main () { float c, f=3D0; int i=3D0; do { c=3Dftc(i); printf("\t\t F=3D%.2f \t\t C=3D%.2f\n",f,c); f++; i++; } while (i<=3D100); } ------=_NextPart_000_002E_01BF3ED6.B2B086E0 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable
Hi there!
 
try changing 5/9 to = 5.0/9.0
The compiler may be interpreting it as = a n integer=20 operation, and as such, it will truncate de decimals, effectively doing = 0 *=20 (f-32).
 
Hope this helps!
 
Pablo M. Dotro
pyd AT sion DOT com    &nbs= p;          =20 pdotro AT USSEnterprise DOT com
= pdotro AT labs DOT df DOT uba DOT ar &nbs= p;  =20 ICQ#: 18144918
http://www.usuarios.sion.com= /abismo
 
----- BEGIN GEEK CODE BLOCK = -----
Version=20 3.12
GCS/S/IT/CM d- s: a23 c++$ UL P+ E W++ N++ o K- w
O? M V? PS = PE- Y+=20 PGP>+ t++ 5+ X+ R+>+++ tv b++ DI? D++
G++ e h! r- = y+
-----END GEEK=20 CODE BLOCK -----
(para decodificar el bloque, visite www.geekcode.com)
----- Original Message -----
From:=20 Jason Yip=20
Newsgroups: = comp.os.msdos.djgpp
Sent: Sunday, December 05, 1999 = 12:03=20 AM
Subject: Why "c" is always = zero??

Can anyone tells me why the value = of "c" is=20 always equal to zero??
How can I correct this?
Thanks a lot!!
 
#include <stdio.h>
float=20 ftc(n)
int n;
{
float c, f; int=20 i;
 for (i=3D0;i<=3Dn;i++){
 c=3D5/9*(f-32)
;
     &= nbsp; =20 }
return c;
}
main ()
{
float c, f=3D0; int=20 i=3D0;
do
{
c=3Dftc(i);
printf("\t\t F=3D%.2f \t\t = C=3D%.2f\n",f,c);
f++;
i++;
} while=20 (i<=3D100);
}
------=_NextPart_000_002E_01BF3ED6.B2B086E0--