Select Language:
cs
C# (mono-2.8)
C (gcc-4.3.4)
C# (mono-2.8)
C++ (gcc-4.3.4)
C++0x (gcc-4.5.1)
Python (python 2.6.4)
Python 3 (python-3.1.2)
Java (sun-jdk-1.6.0.17)
JavaScript (rhino) (rhino-1.6.5)
JavaScript (spidermonkey) (spidermonkey-1.7)
Ruby (ruby-1.9.2)
PHP (php 5.2.11)
Source Code:
// Csharp program to demonstrate arithmetic operation using multicast delegates using System; public delegate double mathsop(int a, int b); class mathsoperations { static double multiply(int a1, int b1) { return a1 * b1; } static double division(int a1, int b1) { return a1 / b1; } static double subtraction(int a1, int b1) { return a1 - b1; } static void Main(string[] args) { mathsop mathsobj1 = new mathsop(multiply); mathsop mathsobj2 = new mathsop(division); mathsop mathsobj3 = new mathsop(subtraction); Console.Write("Enter Num1 : "); int a2 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Num2 : "); int b2 = Convert.ToInt32(Console.ReadLine()); double multiplyresult = mathsobj1(a2, b2); double divisionresult = mathsobj2(a2, b2); double subtractionresult = mathsobj3(a2, b2); Console.WriteLine("Multiplication result {0}", +multiplyresult); Console.WriteLine("Division result {0}", +divisionresult); Console.WriteLine("Subtraction result {0}", +subtractionresult); Console.ReadKey(); } }
Input:
(Data will be submitted to the program on Execution.)
8 2