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
Regarding datatypes
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Hemant SrivastavaRank #581 · 4.2K reputationPosted Oct 31, 2013, 7:25 AM EDT
In this way, you can get 19.5
decimal d = (decimal)39 / 2;
Console.WriteLine(d);
VulpesRank #55 · 29.2K reputationPosted Oct 31, 2013, 8:19 AM EDT
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.