per=(sum/500)*100;
Since, "per" is a integer, suppose if you enter 1,2,3,4,5 as integers,
their sum will be 15 and (15/500) = 0 (since both 15 and 500 are
integers, output is an integer...
To get your code to work properly, you can change the line to:
per=(sum/500.0)*100;
now, one of them is a float, so the result will also be a float..
Hope, what i tried to convey is clear to you.
Regards,
Abhijeet
Uday Oberio wrote:
>
> This is a
>
> void main()
> {
> int m1,m2,m3,m4,m5,sum;
> float per;
> scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
> sum=m1+m2+m3+m4+m5;
> per=(sum/500)*100;
> printf("\n%f",per);
> }
> In this program if i run than the result is always 0.000000, but if i
> take sum as a float than the result is correct. Why? I m confuse. Can
> you explain it?
> thankyou
> With Regards
> Uday
>
> The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
> http://in.yahoo.com/ <http://in.yahoo.com/>
>
> [Non-text portions of this message have been removed]
>
>
--
Abhijeet Rastogi
(shadyabhi)
http://www.google.com/profiles/abhijeet.1989
------------------------------------
To unsubscribe, send a blank message to
<mailto:[email protected]>.Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/c-prog/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/