Identify and correct the error(s) in each of the following:

a) if ( age >= 65 );
cout << "Age is greater than or equal to 65" << endl;
else
cout << "Age is less than 65 << endl";
b) if ( age >= 65 )
cout << "Age is greater than or equal to 65" << endl;
else;
cout << "Age is less than 65 << endl";
c) int x = 1, total;
while ( x <= 10 )
{
total += x;
++x;
}
d) While ( x <= 100 )
total += x;
++x;
e) while ( y > 0 )
{
cout << y << endl;
++y;
}


a) The semicolon at the end of the if condition should be removed. The closing double quote after the second endl should be placed after 65.
b) The semicolon after the else should be removed. The closing double quote after the second endl should be placed after 65.
c) Variable total should be initialized to 0.
d) The W in while should be lowercase. The while’s body should be enclosed in braces {}.
e) The variable y should be decremented (i.e., y--;), not incremented ( y++;).

Computer Science & Information Technology

You might also like to view...

Referring to the accompanying figure, the active cell is cell _____.

A. C9 B. B9 C. A9 D. C10

Computer Science & Information Technology

What was used to make analyzing results faster for the 1890 census?

a. integrated circuits b. processors c. punch cards and punch card readers d. ENIAC

Computer Science & Information Technology

Craigslist is an example of a(n) ________ site

Fill in the blank(s) with correct word

Computer Science & Information Technology

____ areas are similar to text boxes except they display a multiple-line input box, providing a larger area in which visitors can enter text.

A. Content B. Text C. Discussion D. Word

Computer Science & Information Technology