Question: Find the error(s) in each of the following code segments and explain how to correct it: a) i = 1; while (i
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++);
}
Step by Step Solution
3.40 Rating (166 Votes )
There are 3 Steps involved in it
a Error The semicolon after the while header causes an infinite loop and ther... View full answer
Get step-by-step solutions from verified subject matter experts
