Arithmetic Operators:
The arithmetic Operators(+,-,*,/) are operates the two operants.
it processing the two operants and produce result of the operation .
PROGRAM:(ArithmeticEg.cs)
using System;
class ArithmeticEg
{
void addFunction(int a,int b)
{
double result=a+b; //Adding two integer values
Console.WriteLine("Sum of two values is:"+result);
}
void subFunction(float c,float d)
{
float result=c-d; //Subtraction of two integer values
Console.WriteLine("Subtraction of two values is:"+result);
}
void divisionFunction(double e,double f)
{
double result=e/f; //Division of two integer values
Console.WriteLine("Division of two values is:"+result);
}
void moduloFunction(int g,int h)
{
int result=g%h; //Modulo division of two integer values
Console.WriteLine("Modulo division of two values is:"+result);
}
void multiplicationFunction(int i,int p)
{
int result=i*p; //multiplication of two integer values
Console.WriteLine("Multiplication of two values is:"+result);
}
public static void Main(string[] args)
{
ArithmeticEg ip=new ArithmeticEg(); //object creation
ip.addFunction(10,20); // Function calling
ip.subFunction(12.0f,3.9f);
ip.divisionFunction(12,1.1);
ip.multiplicationFunction(12,4);
ip.moduloFunction(13,2);
}
}
OUTPUT:
D:\csharp> ArithmeticEg
Sum of two values is:30
Subtraction of two values is:8.1
Division of two values is:10.9090909090909
Multiplication of two values is:48
Modulo division of two values is:1
PROGRAM EXPLANATION:
The above program performing the arithmetic operation using functions.
it performs the addition,subtraction,Division,Multiplication and Modulo Division.
The arithmetic Operators(+,-,*,/) are operates the two operants.
it processing the two operants and produce result of the operation .
PROGRAM:(ArithmeticEg.cs)
using System;
class ArithmeticEg
{
void addFunction(int a,int b)
{
double result=a+b; //Adding two integer values
Console.WriteLine("Sum of two values is:"+result);
}
void subFunction(float c,float d)
{
float result=c-d; //Subtraction of two integer values
Console.WriteLine("Subtraction of two values is:"+result);
}
void divisionFunction(double e,double f)
{
double result=e/f; //Division of two integer values
Console.WriteLine("Division of two values is:"+result);
}
void moduloFunction(int g,int h)
{
int result=g%h; //Modulo division of two integer values
Console.WriteLine("Modulo division of two values is:"+result);
}
void multiplicationFunction(int i,int p)
{
int result=i*p; //multiplication of two integer values
Console.WriteLine("Multiplication of two values is:"+result);
}
public static void Main(string[] args)
{
ArithmeticEg ip=new ArithmeticEg(); //object creation
ip.addFunction(10,20); // Function calling
ip.subFunction(12.0f,3.9f);
ip.divisionFunction(12,1.1);
ip.multiplicationFunction(12,4);
ip.moduloFunction(13,2);
}
}
OUTPUT:
D:\csharp> ArithmeticEg
Sum of two values is:30
Subtraction of two values is:8.1
Division of two values is:10.9090909090909
Multiplication of two values is:48
Modulo division of two values is:1
PROGRAM EXPLANATION:
The above program performing the arithmetic operation using functions.
it performs the addition,subtraction,Division,Multiplication and Modulo Division.
No comments:
Post a Comment