Pages

Tuesday, April 9, 2013

Add two numbers using C#

Adding two numbers using C# in run time

Here I explained how to add Two numbers in run time.

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            Console.WriteLine("Enter the first value");
            a = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter the second value");
            b = Convert.ToInt32(Console.ReadLine());
            c = a + b;
            Console.WriteLine("Sum is: "+c.ToString());
            Console.ReadLine();
        }
    }
}
Output:

No comments:

Post a Comment