Write a C# program to perform basic arithmetic calculations

PHPz
Release: 2023-08-31 19:09:03
forward
1232 people have browsed it

编写一个 C# 程序来进行基本的算术计算

Let us do the following arithmetic calculation-

Add two operands

Sr.No th> Operators and Description
1
2 -

Subtract the second operand from the first operand

3 *

Multiply the two operands

4 /

Numerator divided by numerator

The following is Example of performing arithmetic calculations using the above operators -

Example

Live Demonstration

using System;

namespace OperatorsApplication {
   class Program {
      static void Main(string[] args) {
         int a = 40;
         int b = 20;
         int c;

         c = a + b;
         Console.WriteLine("Addition: {0}", c);

         c = a - b;
         Console.WriteLine("Subtraction: {0}", c);
     
         c = a * b;
         Console.WriteLine("Multiplication: {0}", c);

         c = a / b;
         Console.WriteLine("Division: {0}", c);

         Console.ReadLine();
      }
   }
}
Copy after login

Output

Addition: 60
Subtraction: 20
Multiplication: 800
Division: 2
Copy after login

The above is the detailed content of Write a C# program to perform basic arithmetic calculations. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template