Coding - practical 4 Flashcards

1
Q

What is the general form of a basic if statement?

A
if (condition)
{
          // do this code
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What happens if the condition in an if statement is true?

A

If the condition is true then the statements enclosed by braces are executed, and if the condition is false the statements are skipped.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are comparison operators?

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What may comparison operators be used to construct?

A

A conditional expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What would the code be to display a warning if the temperature of a boiler exceeds 99 degrees centigrade.?

A

if (temp > 99)
{
std::cout &laquo_space;“Warning water is BOILING\n”;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the general form of a basic if..else statement?

A
if(condition)
{
   //code block 1
}
else
{
  //code block 2
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the general form of a basic else if statement?

A
if(condition1)
{
    //code block 1
}
else if (condition2)
{
   //code block 2
}
else
{
   //code block 3
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe how an else if statement works.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the two arguments within aservePlaySample()?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are nested if statements?

A

On occasions were a more complex decision making process is required, we can place if structures inside other if structures. This is called “nesting”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly