# C# Find the addition of two integer numbers

Example:

``````    Input:
First number: 10
Second number: 20

Output:
Addition of 10 and 20 is = 30``````

Program:

``````using System;
static void Main() {
try{
//declare two variables
int a = 0;
int b = 0;

//input numbers
Console.Write("Enter first number: ");
Console.Write("Enter second number: ");

//calculating sum
int sum = a+b;

Console.WriteLine("Addition of " + a + " and " + b + " is = " + sum);
}
catch(Exception ex){
Console.WriteLine("Error: " + ex.ToString());
}
}
}``````

Output

``````Enter first number: 10
Enter second number: 20
Addition of 10 and 20 is = 30``````

Program:

``````using System;
//defining function
static int sumOfTwoNumber(int x, int y){
return x+y;
}
//main function
static void Main() {
try{
//declare two variables
int a = 0;
int b = 0;

//input numbers
Console.Write("Enter first number: ");
Console.Write("Enter second number: ");

//calculating sum by calling the function
int sum = sumOfTwoNumber(a,b);

Console.WriteLine("Addition of " + a + " and " + b + " is = " + sum);
}
catch(Exception ex){
Console.WriteLine("Error: " + ex.ToString());
}
}
}``````

Output

``````Enter first number: 10
Enter second number: 20
Addition of 10 and 20 is = 30``````