Home for the Programmer, Webmaster and Bloggers

13 December 2018

HOW TO subtract TWO NUMBERS IN C#

Image result for c# image

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Even
{
    class Program
    {
        static void Main(string[] args)
        {
            //THis Part displays the message "supply first value" to the user.
            Console.WriteLine("Supply first value");
            /* This part accept the value to be supplied by the user
          and also the keyword int.parse perform an operation called casting
          on the value supplied by the user coz the compiler will automatically take any
          input as a string.
           */
            int first = int.Parse(Console.ReadLine());
            //THis Part displays the message "supply first value" to the user.
            Console.WriteLine("Supply second value");
            /* This part accept the value to be supplied by the user
         and also the keyword int.parse perform an operation called casting
         on the value supplied by the user coz the compiler will automatically take any
         input as a string.
          */
            int second = int.Parse(Console.ReadLine());
            // This part displays the result of the substraction of variable first and second
            Console.WriteLine("Answer=" +  ( first - second));
            Console.ReadKey();
        }

    }

No comments:

Post a Comment