Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Robert <rkfb1965@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Computed values don't tie up |
| Followup-To | comp.lang.c |
| Date | 2012-04-03 21:37 +0000 |
| Message-ID | <9u15bsF7g3U1@mid.individual.net> (permalink) |
| References | <alpine.LNX.2.00.1204031912440.4639@rebelCode.slacknet> <4F7B482B.2040109@verizon.net> |
Followups directed to: comp.lang.c
James Kuyper wrote:
[...]
>
> This line has one too many double quote characters; your code as
> presented here should not have compiled without diagnostics, so this
> can't be your actual program. Please cut and paste the actual text of
> your program; that will make it much easier to figure out what's going
> wrong.
> Also, if the output from your program does not end with a new-line
> character, the behavior is undefined; on many systems that's not a
> problem, but even where it is permitted, I think it would be better to
> append a '\n' to the printf() format string.
>
> When I correct the issues I've raised above in the obvious ways, and
> type in 32, it prints out 0; so that's another reason to think that this
> in not exactly your actual program.
>
>> return 0;
>> }
(Copy/paste)
/* Converts a Fahrenheit temperature to Celcius */
#include <stdio.h>
#define FREEZING_PT 36.0f
#define SCALE_FACTOR (5.0f / 9.0f)
int main(void)
{
float fahrenheit, celcius;
printf("Enter fahrenheit temperature: ");
scanf("%f", &fahrenheit);
celcius = (fahrenheit - FREEZING_PT) * SCALE_FACTOR;
printf("Celcius equivalent: %.1f\n", celcius);
return 0;
}
sorry...I did just retype it out in my original post, this is the actual
code. I copied it straight from the book into Emacs. I'm on Slackware64
13.37 and have run it within Emacs, within KDevelop and also in xterm. It's
always -2.2. I've now made sure it has a newline at the end and have added
one to printf:
/* Converts a Fahrenheit temperature to Celcius */
#include <stdio.h>
#define FREEZING_PT 36.0f
#define SCALE_FACTOR (5.0f / 9.0f)
int main(void)
{
float fahrenheit, celcius;
printf("Enter fahrenheit temperature: \n");
scanf("%f", &fahrenheit);
celcius = (fahrenheit - FREEZING_PT) * SCALE_FACTOR;
printf("Celcius equivalent: %.1f\n", celcius);
return 0;
}
it still gives 2.2.
--
Robert
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Computed values don't tie up rkfb <rkfb@rebelCode.slacknet> - 2012-04-03 19:29 +0000
Re: Computed values don't tie up James Kuyper <jameskuyper@verizon.net> - 2012-04-03 14:57 -0400
Re: Computed values don't tie up Robert <rkfb1965@googlemail.com> - 2012-04-03 21:37 +0000
Re: Computed values don't tie up Robert <rkfb1965@googlemail.com> - 2012-04-03 21:39 +0000
Re: Computed values don't tie up Ike Naar <ike@iceland.freeshell.org> - 2012-04-03 20:52 +0000
Re: Computed values don't tie up James Kuyper <jameskuyper@verizon.net> - 2012-04-03 16:56 -0400
Re: Computed values don't tie up "BartC" <bc@freeuk.com> - 2012-04-03 22:11 +0100
Re: Computed values don't tie up "BartC" <bc@freeuk.com> - 2012-04-03 21:53 +0100
Re: Computed values don't tie up Robert <rkfb1965@googlemail.com> - 2012-04-03 22:56 +0000
Re: Computed values don't tie up Geoff <geoff@invalid.invalid> - 2012-04-03 20:05 -0700
Re: Computed values don't tie up Martin Ambuhl <mambuhl@earthlink.net> - 2012-04-04 00:38 -0400
Re: Computed values don't tie up "BartC" <bc@freeuk.com> - 2012-04-03 21:04 +0100
Re: Computed values don't tie up Robert <rkfb1965@googlemail.com> - 2012-04-03 21:38 +0000
Re: Computed values don't tie up Kleuske <kleuske@nowhere.net> - 2012-04-03 23:09 +0000
Re: Computed values don't tie up Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-04-04 04:42 +0100
csiph-web