0% found this document useful (0 votes)
32 views

002 Input and Output To Console Example

This C# program takes two numbers as input from the user via the console, adds them together, and displays the sum on the console. It prompts the user to enter the first and second numbers, parses the user input as integers, calculates the sum of the two numbers, and writes out a message to the console displaying the individual numbers and their total sum.

Uploaded by

duskoruzicic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

002 Input and Output To Console Example

This C# program takes two numbers as input from the user via the console, adds them together, and displays the sum on the console. It prompts the user to enter the first and second numbers, parses the user input as integers, calculates the sum of the two numbers, and writes out a message to the console displaying the individual numbers and their total sum.

Uploaded by

duskoruzicic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

/*************************************************************************

* Input and Output to Console Example


*
*************************************************************************/

using System;

namespace MyProject.Examples
{
class ExampleOne
{
static void Main()
{
Console.Write("Please Enter number 1 ");
int x = int.Parse(Console.ReadLine());

Console.Write("Please Enter number 2 ");


int y = int.Parse(Console.ReadLine());

int z = x + y;

Console.Write("The Sum of {0} and {1} is {2}


", x, y,z);
Console.ReadKey();
}
}
}

You might also like