
- 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
C# Program to perform all Basic Arithmetic Operations
Basic Arithmetic Operators in C#, include the following −
Operator | Description |
---|---|
+ | Adds two operands |
- | Subtracts the second operand from the first |
* | Multiplies both operands |
/ | Divides the numerator by de-numerator |
% | Modulus Operator and remainder of after an integer division |
++ | Increment operator increases integer value by one |
-- | Decrement operator decreases integer value by one |
To add, use the Addition Operator −
num1 + num2;
In the same way, it works for Subtraction, Multiplication, Division, and other operators.
Example
Let us see a complete example to learn how to implement Arithmetic operators in C#.
using System; namespace Sample { class Demo { static void Main(string[] args) { int num1 = 50; int num2 = 25; int result; result = num1 + num2; Console.WriteLine("Value is {0}", result); result = num1 - num2; Console.WriteLine("Value is {0}", result); result = num1 * num2; Console.WriteLine("Value is {0}", result); result = num1 / num2; Console.WriteLine("Value is {0}", result); result = num1 % num2; Console.WriteLine("Value is {0}", result); result = num1++; Console.WriteLine("Value is {0}", result); result = num1--; Console.WriteLine("Value is {0}", result); Console.ReadLine(); } } }
Output
Value is 75 Value is 25 Value is 1250 Value is 2 Value is 0 Value is 50 Value is 51
- Related Articles
- Java Menu Driven Program to Perform Basic String Operations
- Golang Program to create a Class that can perform basic Calculator Operations
- How to perform arithmetic operations on a date in Python?
- How to perform the arithmetic operations on arrays in C language?
- How to perform arithmetic operations on two-dimensional array in C?
- Write a C# program to do basic arithmetic calculations
- C++ Program to Perform Operations in a BST
- Write a C program to perform 3X3 matrix operations
- What are Arithmetic Micro-operations?
- C++ Program to Perform Dictionary Operations in a Binary Search Tree
- Arithmetic operations using OpenCV in Python
- Decimal arithmetic operations in Computer Architecture?
- Basic List Operations in Python
- Basic Tuples Operations in Python
- C program to perform operations on two halves’ in a single array

Advertisements