Coding - practical 4 Flashcards
What is the general form of a basic if statement?
if (condition) { // do this code }
What happens if the condition in an if statement is true?
If the condition is true then the statements enclosed by braces are executed, and if the condition is false the statements are skipped.
What are comparison operators?
Symbols that determine the relationship between two values: > Greater than < Less than >= Greater than or equal to <= Less than or equal to == Equal to (different to assignment =) != Not equal to
What may comparison operators be used to construct?
A conditional expression
What would the code be to display a warning if the temperature of a boiler exceeds 99 degrees centigrade.?
if (temp > 99)
{
std::cout «_space;“Warning water is BOILING\n”;
}
What is the general form of a basic if..else statement?
if(condition) { //code block 1 }
else { //code block 2 }
What is the general form of a basic else if statement?
if(condition1) { //code block 1 }
else if (condition2) { //code block 2 }
else { //code block 3 }
Describe how an else if statement works.
If the outcome of condition 1 is true then code block 1 is executed. If the outcome of condition 1 is false then condition 2 is tested and if found to be true then code block 2 is executed, if both condition 1 and condition 2 are false then code block 3 is executed. Only one code block is executed.
What are the two arguments within aservePlaySample()?
- The first argument specifies the sample channel to playback.
- The second argument is the volume to play the sample at, just like the oscillators it has a range from 0 to 1.0.
What are nested if statements?
On occasions were a more complex decision making process is required, we can place if structures inside other if structures. This is called “nesting”