Problem
Write a program in C# to add two integers and display the result on the screen.
C# Program to add two integers
using System;
namespace AbundantcodeCSharpApp
{
class Program
{
static void Main(string[] args)
{
int input1;
int input2;
int result;
Console.Write("\n Enter the first number");
input1 = Convert.ToInt32(Console.ReadLine());
Console.Write("\n Enter the second number");
input2 = Convert.ToInt32(Console.ReadLine());
result = input1 + input2;
Console.Write("\n result " + result);
Console.ReadLine();
}
}
}Output
Enter the first number1
Enter the second number2
result 3
1 Comment