-
Notifications
You must be signed in to change notification settings - Fork 0
/
P.cs
35 lines (31 loc) · 1.18 KB
/
P.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
// Ask the user to input two numbers
Console.WriteLine("Enter the first number: ");
double? num1 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter the second number: ");
double? num2 = Convert.ToDouble(Console.ReadLine());
// Check for null values before performing calculations
if (num1 != null && num2 != null)
{
// Display the addition, subtraction, multiplication, and division of the two numbers
Console.WriteLine("Addition: " + (num1 + num2));
Console.WriteLine("Subtraction: " + (num1 - num2));
Console.WriteLine("Multiplication: " + (num1 * num2));
Console.WriteLine("Division: " + (num1 / num2));
}
else
{
// Handle null values
Console.WriteLine("One or both input values are null.");
}
// Wait for the user to press a key before closing the console window
Console.ReadKey();
}
}
}