int d =39/2;
decimal l=(decimal)d;
Console.Writeline(l);
The output is 19.5
i used double it shows 20(rounding off)
what should i do now to get output as 19 from 19.5
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Oct 31, 2013, 12:19 PM
Are you sure that the code you posted is what you intended to post?
The output is already 19 whether you subsequently convert to decimal or to double.
Hemant SrivastavaPosted Oct 31, 2013, 11:25 AM
In this way, you can get 19.5
decimal d = (decimal)39 / 2;
Console.WriteLine(d);