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...

Which of the following is not a kind of inheritance in C++?

a. public. b. private. c. static. d. protected.

Computer Science & Information Technology

A remote procedure call (RPC) between processes on the same machine is called a(n) _______.

a) local remote procedure call (LRPC) b) local procedure call (LPC) c) deferred procedure call (DPC) d) asynchronous procedure call (APC)

Computer Science & Information Technology

If you want to know what your document would look like as a Web page, you need to use the ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

Word provides all the commands necessary for you to publish your blog directly to the host server for your blog

Indicate whether the statement is true or false

Computer Science & Information Technology