Find the error(s) in each of the following code segments. Explain how to correct the error. a)

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()

{

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;

}

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Visual C# How to Program

ISBN: 978-0134601540

6th edition

Authors: Paul J. Deitel, Harvey Deitel

Question Posted: