C# Program to perform all Basic Arithmetic Operations




 

Method 1 :

using System;

public class csharp{

public static void Main(){

    int a,b;

    double result;

Console.WriteLine(" enter the Number1");

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

    Console.WriteLine(" enter the Number2");

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

      

      result=a+b;

        Console.WriteLine(" Addition is "+result);

      result=a-b;

        Console.WriteLine(" Subtraction is "+result);

      result=a/b;

        Console.WriteLine(" division is "+result);

      result=a*b;

        Console.WriteLine(" Multiplication is "+result);

   

}

}

Method 2 :



using System;

public class csharp{

public static void Main(){

    int a,b;

    double add, sub, div, multi;

Console.WriteLine(" enter the Number1");

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

    Console.WriteLine(" enter the Number2");

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

      

      add=a+b;

      sub=a-b;

      div=a/b;

      multi=a*b;

    Console.WriteLine("Addition  = "+ a+ "+" +b+ "=" +add+"\nSubtraction = "+sub +" \ndivision =  "+ div+ "\nMultiplication = "+multi);

}

}

Method 3 :





using System;
public class csharp{
public static void Main(){
    int a,b;
Console.WriteLine(" enter the Number1");
    a= int.Parse(Console.ReadLine());
    Console.WriteLine(" enter the Number2");
      b= int.Parse(Console.ReadLine());
      
        Console.WriteLine(" Addition is "+ (a+b));
 
        Console.WriteLine(" Subtraction is "+ (a-b));
 
        Console.WriteLine(" division is "+ (a/b));
   
        Console.WriteLine(" Multiplication is "+ (a*b));
   
}
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.