Intro to programming UNIT 3 Flashcards
What is a ternary operator
The ternary operator is a short if else statement in one line. It takes three operands
What operands does a ternary operator take. In what order
- The condition being tested
- Value if true
- Value if false
ex:
condition ? value if true : value if false
What does the && operator do and what is it’s logical table?
The && Operator is for logical AND. Both operands need to be true for it to return as TRUE
side 1 side 2 result
false false false
true false false
false true false
true true true
What does the || operator do and what’s it logic table
The || Operator is for logical OR. Either or both operands need to be true for it to return as TRUE
side 1 side 2 result
false false false
true false true
false true true
true true true
What is the logical not operator?
Using the (!) exlamation mark
How do you invert the && or the || operator?
You add the exclamation mark before
ex:
!||
!&&
What is called an inverse of an or?
NOR or NOT OR
What is the inverse of an and
NAND
What is the Logical XOR or Exclusive OR or Bitwise comparison operator?
Using the caret or ^ symbol
What is the XOR operator truth table?
Both sides cannot be the same for the operator to return as true
false false false
true false true
false true true
true true false
What is the XOR of
0001
0011
Result 0010
What evaluations can you use in a SWITCH statement
You can only use equality operators in a switch evaluation. Therefore you cannot use > < operators only ==
What’s the structure of a switch statement?
switch(toBeEvaluated) {
case 1:
break;
What is default for a switch?
Default is the case that will be run if no matches are found. It needs to be placed at the bottom of the switch case
What is a TRAILING ELSE BLOCK
It’s the default case that executes if none of the other cases evaluate to true