Create an application named Numbers whose main() method holds two integer variables. Assign
values to the variables. Pass both variables to methods named sum () and difference(). Create the
methods sum() and difference(); they compute the sum of and difference between the values of two
arguments, respectively. Each method should perform the appropriate computation and display the
results. Save the application as Numbers.cs
using System;
namespace Test
{
class Numbers
{
static int Main()
{
int a = 20;
int b = 10;
sum(a, b);
difference(a, b);
return 0;
}
static void sum(int a, int b)
{
int result = a + b;
Console.WriteLine("{0} + {1} = {2}", a, b, result);
}
static void difference(int a, int b)
{
int result = a - b;
Console.WriteLine("{0} - {1} = {2}", a, b, result);
}
}
}
Comments
Leave a comment