Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 3 Review Mr. Crone.

Similar presentations


Presentation on theme: "Section 3 Review Mr. Crone."— Presentation transcript:

1 Section 3 Review Mr. Crone

2 True or false? bool x = true; int y = 5, z = 6; (y > z && x )

3 True or false? bool x = true; int y = 5, z = 6; (y > z && x ) // F

4 True or false? bool x = true; int y = 5, z = 6; (y > z || !x )

5 True or false? bool x = true; int y = 5, z = 6; (y > z || !x ) // False!

6 True or false? bool x = true, y = false, z = false (x && !y && !z)

7 True or false? bool x = true, y = false, z = false (x && !y && !z) True!

8 What does the code print?
int x = 4, y = 2, z = 1; if(y ==2) if( z ==1) x += 6; else x =4; x += 8; cout << x << endl;

9 What does the code print?
int x = 4, y = 2, z = 1; if(y ==2) // True if( z ==1) // True x += 6; // x = 10 else x =4; x += 8; cout << x << endl;

10 What does the code print?
int x = 54; if(x>= 5 && x <= 100) x = 4; else x = 5; cout << x << endl;

11 What does the code print?
int x = 54; if(x>= 5 && x <= 100) // True x = 4; // x = 4 else x = 5; cout << x << endl; // 4

12 What does the code print?
bool var = true; bool var2 = false; if( !(!var && var2)) cout << “1”; else cout << “2”;

13 What does the code print?
bool var = true; bool var2 = false; if( !(!var && var2)) // True cout << “1”; // Prints 1 else cout << “2”;

14 What does the code print?
int x = 14; if(x < 10) cout << “1”; if (x > 10) cout << “2”; if ( x >10 && x < 20) cout << “3”; if(x ==10 || x ==14) cout << “4”;

15 What does the code print?
int x = 14; if(x < 10) // false cout << “1”; if (x > 10) // true cout << “2”; if ( x >10 && x < 20) // true cout << “3”; if(x ==10 || x ==14) // true cout << “4”; Prints: 234

16 int x = 4; bool var = true; if( var) cout << “1” ; else if(x==4) cout << “2” ; else if (x ==4 && var) cout << “3”; else cout << “4”;

17 What does the code print?
int x = 4; bool var = true; if( var)// true cout << “1” ; // Prints 1 else if(x==4) cout << “2” ; else if (x ==4 && var) cout << “3”; else cout << “4”;

18 True or False? bool var = false; bool var2 = true; cout << (24/4%4>1 || !var && var2) << endl;

19 True or False? Prints: 1 bool var = false; bool var2 = true;
24/4%4>1 || !var && var2 6 % 4 > 1 || T 2 > 1 || T True || T True Prints: 1

20 const int RADIUS = 3. 14; double num = 5. 5; bool x = false; if(
const int RADIUS = 3.14; double num = 5.5; bool x = false; if(!x) RADIUS += 4; else num= 17; cout << num << endl;

21 const int RADIUS = 3. 14; // ERROR. double num = 5
const int RADIUS = 3.14; // ERROR! double num = 5.5; bool x = false; if(!x) RADIUS += 4; // ERROR! else num= 17; cout << num << endl;

22 int x = 4, y = 5; bool isWorking = false; if(x> 0&& y > 0) isWorking = true; if(isWorking) x = 5; cout << x << y << endl;

23 int x = 4, y = 5; bool isWorking = false; if(x> 0&& y > 0) // True isWorking = true; if(isWorking) // True x = 5; cout << x << y << endl; // 55

24 int x = 4, y = 5; bool isWorking = false; if(x<y) if(isWorking) isWorking = false; else isWorking = true; y = 20; cout << isWorking << endl;

25 int x = 4, y = 5; bool isWorking = false; if(x<y) if(isWorking) isWorking = false; else isWorking = true; y = 20; cout << isWorking << endl; // Prints 1

26 int x = 4; double y = 2. 5; int yx = 3; cout << ((2
int x = 4; double y = 2.5; int yx = 3; cout << ((2*x)/3 < yx && 2 == int(y));

27 int x = 4; double y = 2. 5; int yx = 3; cout << ((2
int x = 4; double y = 2.5; int yx = 3; cout << ((2*x)/3 < yx && 2 == int(y)); // 8/3 < 3 && 2 == 2 // 2 < 3 && 2 ==2 // TRUE

28 List the logical operators in order of precedence with the operator with the highest precedence being listed first.

29 List the logical operators in order of precedence with the operator with the highest precedence being listed first. !, &&, ||

30 Provide two examples of unary operators.

31 Provide two examples of unary operators. ++, --, !

32 What is the decimal equivalent of the following binary number?
110100

33 What is the decimal equivalent of the following binary number?
110100 52

34 Operator Review Relational Operators: <, >, <=, >=, ==, != Logical Operators: !, &&, || Assignment Operator: = Shortcut Assignment Operators: +=, -=, /=, *=, %= Increment Operator: ++ Decrement Operator: -- Arithmetic Operators: +, -, *, /, % Unary Operators (operator on one item): -, !, ++, -- ** Know when to use == vs. =


Download ppt "Section 3 Review Mr. Crone."

Similar presentations


Ads by Google