Question: TRY IT: Using Relational and Logical Operators C++ LAB 4. 1 TRY IT: Using Relational and Logical Operators Step 1: Add the tryIt4A.cpp program in

TRY IT: Using Relational and Logical Operators C++

LAB 4. 1 TRY IT: Using Relational and Logical Operators

Step 1: Add the tryIt4A.cpp program in your Lab4 folder to the project. Below is a copy of the source code lines that contain output statements. Remember that arithmetic operations are done before relational operations and that relational operations are done before logical operations. Recall also that if you output a Boolean variable or the result of a Boolean expression, true displays as a 1 and false displays as a 0.

1 // Lab 4 tryIt4A

10 cout << ( 3 == 4) << endl;

11 cout << ( 3 == 3) << endl;

12 cout << ( 5 == 3 + 2) << endl << endl;

14 cout << (7 > 5) << endl;

15 cout << (7 > 5 + 2) << endl;

16 cout << (2 >= 8 % 3) << endl << endl;

18 cout << (8 < 6) << endl;

19 cout << (3 * 5 < 2 * 9 - 1) << endl;

20 cout << (5 * 4 <= 40 / 2) << endl << endl;

22 cout << (3 != 5) << endl;

23 cout << (3 != 9 - 2 * 3) << endl;

24 cout << (10 != (4 * 5) / 2) << endl << endl;

26 cout << (5 > 6 && 3 < 4) << endl;

27 cout << (5 > 6 || 3 < 4) << endl;

28 cout << (!(7 > 6)) << endl << endl;

30 cout << ( 2 * 3 == 6 && !(1 > 2) ) << endl;

31 cout << ( !(2 * 3 == 6 && 1 > 2) ) << endl;

32 cout << ( !(2 * 3 == 6 && 1 != 2) ) << endl;

Expected Output

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

Observed Output

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

____________

Step 2: Read the source code, paying special attention to the relational and logical operators. Then complete the Expected Output column, writing down the output you think each cout statement will produce.

Step 3: Now compile and run the tryIt4A.cpp program, and look at the output it creates. If the actual output from a cout statement matches what you wrote down, just place a checkmark in the Observed Output column. If it is not the same, write down the actual output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!