Question: If there is an error in the code segment, write error and explain the error. else write output and display the output. We need an
If there is an error in the code segment, write error and explain the error. else write output and display the output. We need an explanation of errors and please write right code. Example; class Multiply { public Multiply(int x, int y) { Console.WriteLine("Production result= {0}", x*y); } public int Product(int a, int b) { return a*b; } } class Program { static void Main(string[ ] args) { Multiply c = new Multiply( ); Console.WriteLine("Result= {0} ", c.Product(3,5)); } } ERROR OR OUTPUT: If a constructor, different from default constructor, is declared, you can not use default constructor until you declare the default constructor QUESTIONS: 1-) class Division { public Division(int a,int b) { } public static void Div(int a, int b) { Console.WriteLine("Result= {0:.##}", 1.0 * a / b); } } class Program { static void Main(string[]args) { Division d = new Division(); Division.Div(3, 5); } } 2-)
class Multiply
{
public static int a, b;
public Multiply(int x,int y)
{
a = x;
b = y;
}
public static int Product()
{
return a * b
}
}
class Program
{
static void Main(string[]args)
{
Multiply c = new Multiply(3, 5);
Console.WriteLine("Result={0}", c.Product());
}
} 3-)
class Circle { private double pi = 3.14; private int radius; public double CArea() { return pi * radius * radius; }
}
class Program { static void Main(string[]args) { Circle e = new Circle(); Circle radius = 10; Console.WriteLine("Area={0:.##}", e.CArea()); } } 4-) class Arithmetic { public int Arithmetic() { private int Product (int a,int b) { return a * b; } } class Program { static void Main(string[]args) Arithmetic a = new Arithmetic(); Console.Writeline("Result={0}", a.Product(3,5)); } } 5-) void Summation(int a,intb) { int result; result = a + b; } public static void Main(string[]args) { Console.Writeline("{0}", Summation(3,5)); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
