Classes and Methods

 using System;

using System.IO;

using System.Linq;

using System.Collections.Generic;


namespace CSharp_Shell

{

 public class calculation

 {

  static int result;

  public static void add(int num1, int num2)

  {

   result = num1 + num2;

   Console.WriteLine(result);

  }

  public static void sub(int num1, int num2)

  {

   result = num1 - num2;

   Console.WriteLine(result);

  }

  public static void mul(int num1, int num2)

  {

   result = num1 * num2;

   Console.WriteLine(result);

  }

  public static void div(int num1, int num2)

  {

   float resultDiv;

   resultDiv = (float)num1 / num2;

   Console.WriteLine(resultDiv);

  }

 }


 public class Program

 {

  public static void Main()

  {

   Console.Write("Enter first num : ");

   int num1 = int.Parse(Console.ReadLine());

   Console.Write("Enter second num : ");

   int num2 = int.Parse(Console.ReadLine());

   //

   calculation.add(num1, num2);

   calculation.sub(num1, num2);

   calculation.mul(num1, num2);

   calculation.div(num1, num2);

  }

 }

}

Comments

Popular Posts