Identify and correct the errors in each of the following sets of code:

```
a) while (c <= 5)
{
product *= c;
++c;

b) if (gender == 1)
{
Console.WriteLine("Woman");
}
else;
{
Console.WriteLine("Man");
}
```

a. Error: The closing right brace of the while statement’s body is missing.
Correction: Add a closing right brace after the statement ++c;.
b. Error: The semicolon after else results in a logic error. The second output statement will always execute.
Correction: Remove the semicolon after else.

Computer Science & Information Technology

You might also like to view...

An OpenOffice Calc spreadsheet consists of one or more individual ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

COGNITIVE ASSESSMENT What is the usual rate of speed for the platters in a hard disk?

A. 2,000 to 4,000 rpm B. 5,400 to 15,000 rpm C. 12,000 to 25,000 rpm D. 24,500 to 36,000 rpm

Computer Science & Information Technology