Horje
c# calculator Code Example
c# calculator
//A simple calculator guide for total c# begginers




//prompts and gathering data
                Console.Write("Enter a number: ");
                int N1 = Convert.ToInt32(Console.ReadLine());

                Console.Write("Enter an operator: ");
                string op = Console.ReadLine();

                Console.Write("Enter a number: ");
                int N2 = Convert.ToInt32(Console.ReadLine());

                //if statements
                if (op == "+")
                {
                    Console.WriteLine(N1 + N2);
                }else if (op == "-")
                {
                    Console.WriteLine(N1 - N2);
                }else if (op == "*")
                {
                    Console.WriteLine(N1 * N2);
                }else if (op == "/")
                {
                    Console.WriteLine(N1 / N2);
                }
                else
                {
                    //if not stated operator, say "error"
                    Console.WriteLine("Error");
                }
            }
            catch
            {
                //if other problem spotted, say "error
                Console.Write("Error");
            }
c# calculator
2
+
3
+
3




Csharp

Related
interface property implementation c# Code Example interface property implementation c# Code Example
c# environment variables Code Example c# environment variables Code Example
decrease image size C# Code Example decrease image size C# Code Example
c# get list of all class fields Code Example c# get list of all class fields Code Example
how to disable click listener in android Code Example how to disable click listener in android Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10