subtract two numbers in csharp

To subtract two numbers in C# you can use the "-" operator. Here's an example:

main.cs
int num1 = 10;
int num2 = 5;

int result = num1 - num2;

Console.WriteLine(result); // Output: 5
97 chars
7 lines

In the above code, we declare two integer variables num1 and num2 with values of 10 and 5 respectively. Then, we subtract num2 from num1 using the "-" operator and store the result in result. Finally, we print the result to the console.

related categories

gistlibby LogSnag