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

1 Expert Approved Answer
Step: 1 Unlock

a Error Method H is declared within method G b Error The method i... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Visual C How Program Questions!