How to divide numbers in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n1 = 10;
            int n2 = 13;

            double d = n1 / n2;
            Console.WriteLine(d);

            d = (double)n1 / n2;
            Console.WriteLine(d);

            d = n1 / (double)n2;
            Console.WriteLine(d);
        }
    }
}

/*
run:

0
0.769230769230769
0.769230769230769

*/

 



answered Jan 23, 2017 by avibootz

Related questions

1 answer 115 views
115 views asked Aug 3, 2022 by avibootz
1 answer 128 views
128 views asked Feb 14, 2017 by avibootz
1 answer 127 views
1 answer 134 views
1 answer 118 views
118 views asked Jan 7, 2022 by avibootz
1 answer 125 views
...