// Add 2 numbers in C#
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter 1st number: ");
string n1, //first number
n2; //2nd number
n1 = Console.ReadLine();
Console.Write("Enter 2nd number: ");
n2 = Console.ReadLine();
int no1, no2;
no1 = Int32.Parse(n1);
no2 = Int32.Parse(n2);
Console.WriteLine("Sum: {0}", no1 + no2);//Change the position of {0} to see what it does.
}
}
}
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter 1st number: ");
string n1, //first number
n2; //2nd number
n1 = Console.ReadLine();
Console.Write("Enter 2nd number: ");
n2 = Console.ReadLine();
int no1, no2;
no1 = Int32.Parse(n1);
no2 = Int32.Parse(n2);
Console.WriteLine("Sum: {0}", no1 + no2);//Change the position of {0} to see what it does.
}
}
}
No comments:
Post a Comment