- Get link
- X
- Other Apps
Arithmetic operators are mainly used to perform mathematical operations. Below are some of the examples are given:C# example for the Arithmetic Operators
1."+"(Addition):-This operator are used to adding of two numbers, String Concatenation,
2."-"(Subtraction):-This operator is used to subtract the second operand from the first operand,
3."*"(Multiplication):-This operator is used to Multiply two operands,
4."/"(Divide):-This operator is used to divide the numerator from the denominator,
5."%"(Modulus):-This is used to get the Remainder.
Below is the Example Program in C# for the above Arithmetic Operators:
using System;
namespace Arithmetic_Operators
{
class Program
{
static void Main(string[] args)
{
//Initialising the values
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();
}
}
} 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.3333333
Remainder of 10 and 3 is = 1
Conclusion:-
In the above example, we are seen that the arithmetic operators by using these operators we will do the mathematical operations very easily.
- Get link
- X
- Other Apps



Comments
Post a Comment