If Statements Flashcards
1
Q
Give 6 examples of comparison operators.
A
> , < , >=, <=, !=, ===
2
Q
What data type do comparison expressions evaluate to?
A
Boolean
3
Q
What is the purpose of an if statement?
A
A decision-making statement that guides a program to make decisions based on specified criteria
4
Q
Is else required in order to use an if statement?
A
The else statement is not mandatory and will execute only if the if condition fails.
5
Q
Describe the syntax (structure) of an if statement.
A
if ( condition) { }
if statement, condition, code block (else code block).
6
Q
What are the three logical operators?
A
And, Or, Not
7
Q
How do you compare two different expressions in the same condition?
A
Using logical operators