ให้เราทำการคำนวณทางคณิตศาสตร์ต่อไปนี้ -
| Sr.No | ตัวดำเนินการ &คำอธิบาย |
|---|---|
| 1 | + เพิ่มตัวถูกดำเนินการสองตัว |
| 2 | - ลบตัวถูกดำเนินการที่สองจากตัวแรก |
| 3 | * คูณทั้งสองตัวถูกดำเนินการ |
| 4 | / หารตัวเศษด้วยตัวลบ |
ต่อไปนี้คือตัวอย่างการคำนวณทางคณิตศาสตร์โดยใช้ตัวดำเนินการที่ให้มาข้างต้น -
ตัวอย่าง
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();
}
}
} ผลลัพธ์
Addition: 60 Subtraction: 20 Multiplication: 800 Division: 2