Question: Find the error(s) in each of the following code segments. Explain how to correct the error. a) void G() { Console.WriteLine(Inside method G); void H()
Find the error(s) in each of the following code segments. Explain how to correct the error.
a) void G()
{
Console.WriteLine("Inside method G");
void H()
{
Console.WriteLine("Inside method H");
}
}
Correction: Move the declaration of H outside the declaration of G.
b) int Sum(int x, int y)
{
int result;
result = x + y;
}
c) void F(float a);
{
float a;
Console.WriteLine(a);
}
d) void Product()
{
int a = 6, b = 5, c = 4, result;
result = a * b * c;
Console.WriteLine("Result is " + result);
return result;
}
Step by Step Solution
3.53 Rating (167 Votes )
There are 3 Steps involved in it
a Error Method H is declared within method G b Error The method i... View full answer
Get step-by-step solutions from verified subject matter experts
