Identify and correct the errors in each of the following statements (assume that the state- ment using std::cout; is used):

a) if ( c < 7 );
cout << "c is less than 7\n";
b) if ( c => 7 )
cout << "c is equal to or greater than 7\n";


a) Error: Semicolon after the right parenthesis of the condition in the if statement. Correction: Remove the semicolon after the right parenthesis. [Note: The result of this error is that the output statement will be executed whether or not the condition in the if statement is true.] The semicolon after the right parenthesis is a null (or empty) statement—a statement that does nothing. We’ll learn more about the null statement in the next chapter.
b) Error: The relational operator =>. Correction: Change => to >=, and you may want to change “equal to or greater than” to “greater than or equal to” as well.

Computer Science & Information Technology

You might also like to view...

A GUI is being designed that will detect and respond to a mouse event. How many methods must appear in the listener object for the event?

a) 1 b) 2 c) 3 d) 4 e) 5

Computer Science & Information Technology

Why is it an error to add a const modifier, as shown to the declaration for the member function input given here?

``` class BankAccount { public: void input( ) const; // other members }; ```

Computer Science & Information Technology

Which of the following scenarios would provide for an ideal use of the ReFS file system?

A. A small storage drive in which users will use compression to save disk space B. A volume requiring strict encryption of confidential information C. A volume on which administrators can control disk space utilization D. A volume requiring high reliability for applications using very large files

Computer Science & Information Technology

Case Based Critical ThinkingCase 1You are in the planning stages of designing a website to market cookbooks.  Answer the following questions about planning the site. Which program will you use to edit the photos you want to post on the website?

A. Dreamweaver B. Illustrator C. Photoshop D. Premiere Pro

Computer Science & Information Technology