arithmetic operations in C# like Add Subtract Divide and Multiply using a Class Named Here Math Class.
Main Program
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Classes { class Program { static void Main(string[] args) { Console.Write("Enter Your First Number = "); int x = int.Parse(Console.ReadLine()); Console.Write("Enter Your 2nd Number = "); int y = int.Parse(Console.ReadLine()); math operation = new math(); operation.Add(x, y); operation.Sub(x, y); operation.divide(x, y); operation.multi(x, y); Console.ReadLine(); } } }Math Class With Operations
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Classes { class math { public int Add(int x, int y) { Console.WriteLine("The Sum of Your Numbers =" + (x + y)); return 0; } public int Sub(int x, int y) { Console.WriteLine("The Differnce of Your Numbers =" + (x-y)); return 0; } public int multi(int x, int y) { Console.WriteLine("The multiplication of Your Numbers =" + (x * y)); return 0; } public int divide(int x, int y) { Console.WriteLine("The Divsion of Your Numbers =" +(x/y)); return 0; } } }
No comments:
Post a Comment