Tuesday, 17 September 2013

Console Application : Addition Of Two Numbers.

Create New Console Application Program As We Did In Previous Lesson..
I Named My Project As ConsoleAddition.
You Can Use Your Own Name.
When Your Program.cs window appears Change That Code With Below Code.

Program.cs


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

namespace ConsoleAddition
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1, num2;
            Console.WriteLine("Enter the first number:-");
            num1 = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter the Second number:-");
            num2 = int.Parse(Console.ReadLine());


            int result = num1 + num2;

            Console.WriteLine("Addition is : " + result);
            Console.ReadLine();
        }
    }
}


 
In Above Program num1 , num2 Are Two Integers Which Has Been Parsed To Scan Numbers.
result is the Output Integer Which Adds num1 and num2 Integer.
Choose the F5 key to run the project. A Command Prompt window appears that contains the line "Enter First Number" Enter It Then Enter Second Number And Then Press Enter Your Addition Of Two Number Will Appear On The Output Screen.
 
My Output 

  All The Best:)


No comments:

Post a Comment