Home » C# » C# programs » C# basic programs

# C# program to demonstrate example of arithmetic operators

**C# example for arithmetic operators**: Here, we are writing a **C# program to demonstrate example of all arithmetic operators**.

Submitted by **IncludeHelp**, on April 06, 2019

Arithmetic operators are used to perform mathematic operations, here is the list of all C# arithmetic operators,

**"+" (Addition)**– it is used to add two number, string concatenation**"-" (Subtraction)**– it is used to subtract second operand from first operand**"*" (Multiplication)**– it is used to multiply two operands**"/" (Divide)**– it is used to divide numerator from de-numerator**"%" (Modulus)**- it is used to get remainder

**Example:**

Input: int a = 10; int b = 3; //operations int sum = a + b; int sub = a - b; int mul = a * b; float div = (float)a / (float)b; int rem = a % b; Output: sum = 13 sub = 7 mul = 30 div = 3.333333 rem = 1

**C# code to demonstrate example of arithmetic operators**

// C# program to demonstrate example of // arithmetic operators using System; using System.IO; using System.Text; namespace IncludeHelp { class Test { // Main Method static void Main(string[] args) { int a = 10; int b = 3; int sum = a + b; int sub = a - b; int mul = a * b; float div = (float)a / (float)b; int rem = a % b; Console.WriteLine("Addition of {0} and {1} is = {2}", a, b, sum); Console.WriteLine("Subtraction of {0} and {1} is = {2}", a, b, sub); Console.WriteLine("Multiplication of {0} and {1} is = {2}", a, b, mul); Console.WriteLine("Division of {0} and {1} is = {2}", a, b, div); Console.WriteLine("Remainder of {0} and {1} is = {2}", a, b, rem); //hit ENTER to exit the program Console.ReadLine(); } } }

**Output**

Addition of 10 and 3 is = 13 Subtraction of 10 and 3 is = 7 Multiplication of 10 and 3 is = 30 Division of 10 and 3 is = 3.333333 Remainder of 10 and 3 is = 1

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.