This website completely moved to new platform. For latest content, visit www.programmingposts.com

Search this Site

19 Feb 2013

Simple C# Program To Add Two Numbers / Integers



C# PROGRAM TO ADD TWO NUMBERS / INTEGERS :

using System;
 
namespace CsharpPrograms
{
    class Program
    {
        static void Main(string[] args)
        {
 
            int x;
            int y;
            int result;
            Console.Write("\n Enter the first number to be added: ");
            x=Convert.ToInt32(Console.ReadLine());
            Console.Write("\n Enter the second number to be added: ");
            y = Convert.ToInt32(Console.ReadLine());
            result = x + y;
            Console.Write("\n The sum of two numbers is: "+result);
            Console.ReadLine();
        }
    }
}

Output:




For C program: c program for adding two numbers / integers