Using user defined Method
// Method user defined
Console.WriteLine("Enter First Number");
int a = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Second Number");
int b = int.Parse(Console.ReadLine());
Console.WriteLine("1-SUM");
Console.WriteLine("2-SUBTRACTION");
Console.WriteLine("3-MULTIPLICATION");
Console.WriteLine("4-DEVISION");
Console.WriteLine("5-MODE");
int sum = a + b;
int sub = a - b;
int mul = a * b;
double dev = a / b;
int mod = a % b;
Console.WriteLine();
int c = int.Parse(Console.ReadLine());
switch (c)
{
case 1:
Console.WriteLine(sum);
break;
case 2:
Console.WriteLine(sub);
break;
case 3:
Console.WriteLine(mul);
break;
case 4:
Console.WriteLine(dev);
break;
case 5:
Console.WriteLine(mod);
break;
default:
Console.WriteLine("Enter the correct value");
break;
}
Console.ReadLine();
No comments:
Post a Comment