Answer to Question #243800 in C# for mack

Question #243800

 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


1
Expert's answer
2021-09-28T13:11:18-0400
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);
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS