
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are arithmetic operators in C#?
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
Operator | Description | Example |
---|---|---|
+ | Adds two operands | A + B = 30 |
- | Subtracts second operand from the first | A - B = -10 |
* | Multiplies both operands | A * B = 200 |
/ | Divides numerator by de-numerator | B / A = 2 |
% | Modulus Operator and remainder of after an integer division | B % A = 0 |
++ | Increment operator increases integer value by one | A++ = 11 |
-- | Decrement operator decreases integer value by one | A-- = 9 |
Let us see an example to use arithmetic operators in C#.
Example
using System; namespace Demo { class Program { static void Main(string[] args) { int a = 99; int b = 33; int c; c = a + b; Console.WriteLine("Value of c is {0}", c); c = a - b; Console.WriteLine("Value of c is {0}", c); c = a * b; Console.WriteLine("Value of c is {0}", c); c = a / b; Console.WriteLine("Value of c is {0}", c); c = a % b; Console.WriteLine("Value of c is {0}", c); c = a++; Console.WriteLine("Value of c is {0}", c); c = a--; Console.WriteLine("Value of c is {0}", c); Console.ReadLine(); } } }
Output
Value of c is 132 Value of c is 66 Value of c is 3267 Value of c is 3 Value of c is 0 Value of c is 99 Value of c is 100
- Related Articles
- What are Arithmetic Operators in JavaScript?
- What are the arithmetic operators in Java?
- What are different arithmetic operators in Python?
- What are the arithmetic and character operators in DBMS?
- Arithmetic Operators in C++
- Python Arithmetic Operators
- Java arithmetic operators
- Perl Arithmetic Operators
- What is operand of arithmetic operators in Java
- Arithmetic operators in Dart Programming
- Simple Arithmetic Operators Example Program In C++
- Why in MySQL, we cannot use arithmetic operators like ‘=’, ‘
- Explain the concept of Arithmetic operators in C language
- What are operators in JavaScript?
- What are Arithmetic Micro-operations?

Advertisements