Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion difference between statement
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
BartC  
View profile  
 More options May 3 2012, 11:23 am
Newsgroups: comp.lang.c
From: "BartC" <b...@freeuk.com>
Date: Thu, 3 May 2012 16:23:26 +0100
Local: Thurs, May 3 2012 11:23 am
Subject: Re: difference between statement

"ashu" <ashishmoury...@gmail.com> wrote in message

news:b101f606-7c9f-49e0-9784-b5300eacc86d@k10g2000pbk.googlegroups.com...

> #include<stdio.h>
> #include<conio.h>

> main()
> {
>    float fahr,celsius;

>      celsius= -17;
>      fahr=celsius * (9/5) + 32;
>      printf("%3.1f\n",fahr);

> getch();
> }
> Result is 15.0
> but when i write: fahr=celsius * 9/5 + 32;
> result is : 1.4

Using floating point constants instead, such as 9.0/5.0, otherwise integer
arithmetic can sometimes give these funny results (9/5 is 1 according to C).

--
Bartc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.