Integer division without exception handling. - CSharp Language Basics

CSharp examples for Language Basics:int

Description

Integer division without exception handling.

Demo Code


using System;/*w ww.  j  a v  a2s.  c  o m*/

class MainClass
{
   static void Main()
   {
      // get numerator
      Console.Write("Please enter an integer numerator: ");
      var numerator = int.Parse(Console.ReadLine());

      var denominator = 0;

      // divide the two integers, then display the result
      var result = numerator / denominator;
      Console.WriteLine($"\nResult: {numerator} / {denominator} = {result}");
   }
}

Result


Related Tutorials