Sie sind auf Seite 1von 3

Method

Write a C# program that compute the absolute value of number using class.
namespace ConsoleApplication20
{
class absvalue {
public double abs(double x) {
return Math.Abs(x);

}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the number");
int x;
x = Convert.ToInt32(Console.ReadLine());
absvalue abs1 = new absvalue();
double absnum = abs1.abs(x);
Console.WriteLine("the abs value is={0}", absnum);
Console.ReadKey();
}
}
}

Write a C# program that compute the Maximum number using class.


namespace ConsoleApplication20
{
class maxvalue {
public int max(int x,int y) {
return Math.Max(x,y);

}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the first number");
int x;
x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter the second number");
int y;
y = Convert.ToInt32(Console.ReadLine());
maxvalue m1 = new maxvalue();
int maxnum = m1.max(x, y);
Console.WriteLine("maximum number is={0}", maxnum );
Console.ReadKey();
}
}
}

H.W:

Write a C# program that compute the Minimum number using class.

Write a C# program that compute the square root value of number using class.

namespace ConsoleApplication20
{
class Sequarroot {
public double sqrt(double x) {
return Math.Sqrt(x);

}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the number");
int x;
x = Convert.ToInt32(Console.ReadLine());
Sequarroot seq1 = new Sequarroot();
double seq = seq1.sqrt(x);
Console.WriteLine("the sequar root of number is={0}", seq);
Console.ReadKey();
}
}
}