0% found this document useful (0 votes)
16 views2 pages

Assignment 1 APT1030 A

Computer science

Uploaded by

kmdjd2cmzq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Assignment 1 APT1030 A

Computer science

Uploaded by

kmdjd2cmzq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

KITILI MOURINE MBULA-665763

SOLUTION
using System;

namespace FunctionsExample
{
class Program
{
public static int Add(int x, int y)
{
int total = x + y;
return total;
}
public static int Subtract(int x, int y)
{
int subtraction = x * y;
return subtraction;
}
public static int Multiply(int x, int y)
{
int Multiplication = x - y;
return Multiplication;
}
public static int Divide(int x, int y)
{
int Division = x / y;
return Division;
}
static void Main(string[] args)
{
int a, b, X, Y,Z,T;
int choice;

Console.Write("Number 1: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Number 2: "); b =
Convert.ToInt32(Console.ReadLine());
Console.Write("=========Enter a choice============= \n");
Console.Write("1. Add \n");
Console.Write("2. Subtract \n");
Console.Write("3. Multiply \n");
Console.Write("4. Divide \n");
Console.Write("5. Exit \n");
Console.Write("=========Enter a choice============= \n");
choice = Convert.ToInt32(Console.ReadLine());
switch(choice)
{ case 1:
X = Add(a, b);
Console.WriteLine("{0} + {1} = {2}", a, b, X);
break; case 2:
Y = Subtract(a, b);
Console.WriteLine("{0} - {1} = {2}", a, b, Y);
break; case 3:
Z = Multiply(a, b);
Console.WriteLine("{0} * {1} = {2}", a, b, Z);
break; case 4:
T = Divide(a, b);

Console.WriteLine("{0} / {1} = {2}", a, b, T);


break; default:
Console.WriteLine("Sorry you entered a wrong choice");
break;
}

Console.ReadKey();

}
}
}

You might also like