Find the error(s) in each of the following code segments and explain how to correct it: a)

Question:

Find the error(s) in each of the following code segments and explain how to correct it:

a) i = 1;
while (i <= 10);
++i;
}

b) for (k = 0.1; k != 1.0; k += 0.1)
{
Console.WriteLine(k);
}

c) switch (n)
{
case 1:
Console.WriteLine("The number is 1");
case 2:
Console.WriteLine("The number is 2");
break;
default:
Console.WriteLine("The number is not 1 or 2");
break;
}

d) The following code should display the values 1 to 10:
n = 1;
while (n < 10)
{
Console.WriteLine(n++);
}

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: