Question #320405

1. 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


Expert's answer

 internal class Program
    {
        static void Main(string[] args)
        {
            int a = 10,
                b = 5;
            Console.Write($"First number: {a}");
            Console.Write($"Second number: {b}");
            Sum(a, b);
            Difference(a, b);
            Console.ReadKey();
        }
        public static void Sum(int a, int b)
        {
            Console.WriteLine($"{a} + {b} = {a + b}");
        }
        public static void Difference(int a, int b)
        {
            Console.WriteLine($"{a} - {b} = {a - b}");
        }
    }
LATEST TUTORIALS
APPROVED BY CLIENTS