The goal of this lab is to give the student more experience
The goal of this lab is to give the student more experience with functions. You will write a C# console application that takes two integer numbers. The program will then call functions to computer the following values:
The sum of the numbers.
The Difference of the numbers.
The Average of the numbers.
The program will display all these values/results. Again; the results must be computed by function calls and displayed accordingly.
Again, I need the program to use CALL FUNCTIONS and to display the Sum, Difference, and Average of the two numbers...having a difficult time figuring this one out.
Solution
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
int x,y,result=0;
Console.WriteLine(\">>> PROGRAM OUTPUT<<< \");
Console.Write(\"\ Enter the first number to be added: \");
x=Convert.ToInt32(Console.ReadLine());
Console.Write(\"\ Enter the second number\");
y = Convert.ToInt32(Console.ReadLine());
result= Add(x,y);
result1= Sub(x,y);
result2= Avg(x,y)
Console.WriteLine(\"\ The sum of two numbers is: {0} \",result);
Console.WriteLine(\"\ The sum of two numbers is: {0} \",result1);
Console.WriteLine(\"\ The sum of two numbers is: {0} \",result2);
Console.ReadLine();
}
static public int Add(int a, int b)
{
int result = a + b;
return result;
}
static public int Sub(int a, int b)
{
int result1 = a-b;
return result1;
}
static public int Avg(int a, int b)
{
int result2 = (a+b)/2;
return result2;
}
}
}

