# question

## How to make arithmetical operations in C#?

I'm making a calculator, and I don't know what signs needs to be for Addition, Subtraction and Division.

``````   if (aritmeticalOperation == "Multiplication") //It can be other operation too.
{
long num01;
Int64 num02;

Console.Write("\n\nType a number to be multiplied: ");
Console.Write("Type another number: ");
Console.WriteLine("\nThe result is " + num01 * num02); //multiplication works but I don't know what should I put for other operations.
while (Console.ReadKey().Key != ConsoleKey.Enter) ;
}
``````

Thanks for help ;)

· 2

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You mean like this?

``````int a = 10;
int b = 5;

Console.WriteLine(a + b); // Addition
Console.WriteLine(a - b); // Subtraction
Console.WriteLine(a * b); // Multiplication
Console.WriteLine(a / b); // Division``````
0 Votes 0 ·

@Singad-4815, May I know if you have got any chance to check my answer? I am glad to help if you have any others questions.

0 Votes 0 ·

@Singad-4815, based on my research, you could try the following code to make make arithmetical operations in C#.

``````  while (true)
{
double x = Convert.ToDouble(Console.ReadLine());
double y = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("// Please input opeartions //");

string z = Console.ReadLine();
switch (z)
{
case "+":
Console.WriteLine("// Result is //");
Console.WriteLine(x+y);
break;
case "-":
Console.WriteLine("// Result is //");
Console.WriteLine(x-y);
break;
case "*":
Console.WriteLine("// Result is //");
Console.WriteLine(x*y);
break;
case "/":
if (y == 0)
{
Console.WriteLine("Result is 0");
}
else
{
Console.WriteLine("// Result is //");
Console.WriteLine(x/y);
}
break;
}
Console.WriteLine("Do you want to exit ?! Y:N?");
char Terminat = Console.ReadKey().KeyChar;
if (Terminat == 'Y' || Terminat == 'y')
{
break;
}

}
``````

Result: 