SUNIL GUTTA

SUNIL GUTTA

  • NA
  • 1k
  • 392.9k

unable to get percentage in decimal values ?

Mar 1 2013 10:35 AM
Hie friends

I Have written this code in note pad i am trying to pass values via command prompt i.e 
after compiling : csc cmdparams.cs then after 

 i am passing cmdparams 70 75 64 58 79 83 73 50

using System;
class cmdparams
{
    static void Main(string[] args)
    {
        int sum = 0;
       double per = 0;
        foreach (string str in args)
            sum += int.Parse(str);
        per = Convert.ToInt32(sum * 100 / 750);

        Console.WriteLine("sum is {0}", sum);
        Console.WriteLine("percentage is {0}", per);
        Console.ReadLine();
    }

}

problem here is when i calculate percentage i am getting round figure like 73 but in reality its 73.6 .. 
-->> Here i want to display output in cmd-prompt with decimals ??

Is there any way ?

Thank you 


Answers (3)