Read user input from console application and do manipulation

Karthikanbarasan
Posted by Karthikanbarasan under C# category on | Points: 40 | Views : 8172
This code Reads user input from console application and do manipulation

class Program
{
static void Main(string[] args)
{
double firstNumber, secondNumber;
string userName;
Console.WriteLine("Enter your name:");
userName = Console.ReadLine();
Console.WriteLine("Welcome {0}!", userName);
Console.WriteLine("Now give me a number:");
firstNumber = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Now give me another number:");
secondNumber = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber,
secondNumber, firstNumber + secondNumber);

Console.ReadKey();
}
}

Comments or Responses

Login to post response