Analyze the following code fragments that assign a boolean value to the variable even.
```
Code 1:
if (number % 2 == 0)
even = true;
else
even = false;
Code 2:
even = (number % 2 == 0) ? true: false;
Code 3:
even = number % 2 == 0;
```
a. Code 2 has a compile error, because you cannot have true and false literals in the conditional expression.
b. Code 3 has a compile error, because you attempt to assign number to even.
c. All three are correct, but Code 1 is preferred.
d. All three are correct, but Code 2 is preferred.
e. All three are correct, but Code 3 is preferred.
e. All three are correct, but Code 3 is preferred.
You might also like to view...
Answer the following statements true (T) or false (F)
1. The following two C++ statements perform the same operation. 2. If number is an int variable, both of the following statements will print out its value: 3. The following two statements could be used interchangeably in a C++ program. 4. The following statements both declare the variable num to be an integer. 5. If a variable is defined as
The only way to rename a section is to Right Click the Section tab, and click Rename
Indicate whether the statement is true or false
Answer the following statement(s) true (T) or false (F)
Experts should be paid in full for all previous work and for the anticipated time required for testimony.
Explain the function of the Color panel with regard to gradients. Include a definition of color stop in your response.
What will be an ideal response?