C# Online Compiler
Example: Arithmetic Operators in C#
C
C++
C#
Java
Python
PHP
main.cs
STDIN
Run
// Arithmetic Operators in C# using System; public class W3CW { // It's the driver function static public void Main (string[] args) { Console.WriteLine("Enter any two positive integer numbers:\n"); int p = Convert.ToInt32(Console.ReadLine()); int q = Convert.ToInt32(Console.ReadLine()); int sum, sub, mul, mod; float div; // It will perform all arithmetic operations sum = p + q; sub = p - q; mul = p * q; div = (float)p / q; mod = p % q; // It will print the final output Console.WriteLine("Addition of "+p+" + "+q+" = "+sum); Console.WriteLine("Subtraction of "+p+" - "+q+" = "+sub); Console.WriteLine("Multiplication of "+p+" * "+q+" = "+mul); Console.WriteLine("Division of "+p+" / "+q+" = "+div); Console.WriteLine("Modulus of "+p+" % "+q+" = "+mod); } }
9 6
Output
Clear
ADVERTISEMENTS