- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a C# program to do basic arithmetic calculations
Let us do the following arithmetic calculations −
Sr.No | Operator & Description |
---|---|
1 | + Adds two operands |
2 | - Subtracts second operand from the first |
3 | * Multiplies both operands |
4 | / Divides numerator by de-numerator |
The following is an example to perform arithmetic calculations using the above-given operators −
Example
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(); } } }
Output
Addition: 60 Subtraction: 20 Multiplication: 800 Division: 2
Advertisements