Resolved How to make arithmetical operations?

Singad

New member
Joined
Oct 19, 2021
Messages
2
Programming Experience
5-10
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.

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


                        Console.Write("\n\nType a number to be multiplied: ");
                        num01 = Convert.ToInt64(Console.ReadLine());
                        Console.Write("Type another number: ");
                        num02 = Convert.ToInt64(Console.ReadLine());
                        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 ;)
 
Solution
I found the answer, in case someone is interested what the answer is here's an example:

C#:
if (aritmeticalOperation == "Addition")

{

                        long num01;

                        long num02;

                        long sum;



                        Console.Write("\n\nType a number to be added: ");

                        num01 = Convert.ToInt64(Console.ReadLine());

                        Console.Write("Type another number: ");

                        num02 = Convert.ToInt64(Console.ReadLine());
                        sum = num01 + num02;
                        Console.WriteLine("\nThe result is " + sum);
                        while (Console.ReadKey().Key != ConsoleKey.Enter) ;
}
I found the answer, in case someone is interested what the answer is here's an example:

C#:
if (aritmeticalOperation == "Addition")

{

                        long num01;

                        long num02;

                        long sum;



                        Console.Write("\n\nType a number to be added: ");

                        num01 = Convert.ToInt64(Console.ReadLine());

                        Console.Write("Type another number: ");

                        num02 = Convert.ToInt64(Console.ReadLine());
                        sum = num01 + num02;
                        Console.WriteLine("\nThe result is " + sum);
                        while (Console.ReadKey().Key != ConsoleKey.Enter) ;
}
 
Solution

Latest posts

Back
Top Bottom