All Type Coding

Search Here

Two Number subtraction,addition,multiplication and division Program in c#.

using System;

class abc
{
    double a, b, c;
    public void sum()
    {
        Console.WriteLine("sum : ");
        Console.WriteLine("Enter first no ");
        a = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Enter second no ");
        b = Convert.ToDouble(Console.ReadLine());
        c = a + b;
        Console.WriteLine("Result is:{0} ", c);
    }
    public void diff()
    {
        Console.WriteLine("Difference : ");
        Console.WriteLine("Enter first no ");
        a = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Enter second no ");
        b = Convert.ToDouble(Console.ReadLine());
        c = a - b;
        Console.WriteLine("Result is " + c);
    }
    public void mul()
    {
        Console.WriteLine("Multiplication :");
        Console.WriteLine("Enter first no");
        a = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Enter second no");
        b = Convert.ToDouble(Console.ReadLine());
        c = a * b;
        Console.WriteLine("Result is : " + c);
    }
    public void div()
    {
        Console.WriteLine("Division : ");
        Console.WriteLine("Enter first no : ");
        a = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Enter second no ");
        b = Convert.ToDouble(Console.ReadLine());
        c = a / b;
        Console.WriteLine("Result is " + c);
        Console.ReadKey();
    }
}
class aa
{
    public static void Main(string[] ars)
    {
        abc a = new abc();
        a.sum();
        a.diff();
        a.mul();
        a.div();
    }

}
Output:


No comments :

Post a Comment