• Language

    C#

  • Description

    It takes two numbers from the keyboard and subtracts the smaller number from the larger one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;

namespace AbsoluteDifferenceBetweenTwoNumbers
{
    class AbsoluteDifferenceBetweenTwoNumbers
    {
        static void Main(string[] args)
        {
            double a, b, difference;
            Console.Write("Enter the value of a: ");
            a = double.Parse(Console.ReadLine());
            Console.Write("Enter the value of b: ");
            b = double.Parse(Console.ReadLine());
            if(a>b)
                difference=a-b;
            else
                difference=b-a;
            Console.WriteLine("Value of difference: " + difference);
            Console.WriteLine();
            Console.Write("Press any key to finish . . . ");
            Console.ReadKey();
        }
    }
}