Structured Programming Test
Back to activity index

Structured Programming Test

Fill in the form below and click the [Mail to Instructor] button to mail your answers to the instructor.

Administrative Information

Please select your group from the list:

Name of the Captain:

E-mail address of the Captain:

Name of the Recorder:

E-mail address of the Recorder:

Name of the Reflector:

E-mail address of the Reflector:


Vocabulary

Select the best answer for each question below:
  1. Compound statements.
    1. Statements enclosed between curly brackets, taking the place of a single statement.
    2. Statements having a combination of artihmetic operations.
    3. Statements having a condition in them.
  2. What are if statements?
    1. Statements that only execute certain substatements if a condition is true.
    2. Statements that are executed repeatedly.
  3. What are logical expressions?
    1. Expressions that can have only the values true and false.
    2. Expressions that are written in the logical order.
  4. Logical expressions
    1. are like arithmetic expressions, but they evaluate to true or false instead of to a number.
    2. cannot be used inside the parentheses of if statements.
    3. cannot be used inside the parentheses of else if statements.
    4. cannot be used inside the parentheses of for statements.
    5. cannot be used inside the parentheses of while statements.
  5. Logical operators
    1. combine logical values like arithmetic operators (+, -, *, /) combine numbers.
    2. cannot be used inside the parentheses of if statements.
    3. cannot be used inside the parentheses of else if statements.
    4. cannot be used inside the parentheses of for statements.
    5. cannot be used inside the parentheses of while statements.
  6. What does C++ do if you give it a number where it wants a true or false value?
    1. It refuses to compile.
    2. It crashes during execution.
    3. It stupidly takes any nonzero value to be ``true", and zero to be ``false".
  7. if/else statement.
    1. A way to execute different statements or compound statements for a series of possible conditions.
    2. A way to repeat statements multiple times.
    3. A way to execute one statement or compound statement if a condition is true, another if it is false.
  8. if/else if/.../else ladder.
    1. A way to execute different statements or compound statements for a series of possible conditions.
    2. A way to repeat statements multiple times.
    3. A way to execute one statement or compound statement if a condition is true, another if it is false.
  9. for loops.
    1. Allow you to repeat a statement or compound statement using a counter.
    2. Allow you to repeat a statement or compound statement until a condition is no longer true.
    3. Allow you to do both, but you should really use a while loop in the second case.
  10. while loops.
    1. Allow you to repeat a statement or compound statement using a counter.
    2. Allow you to repeat a statement or compound statement until a condition is no longer true.
    3. Allow you to do both, but you should really use a for loop in the first case.

Critical Thinking Questions

Select the best answer:
  1. What is the difference in results from the left and right program parts:
        if (1 == 2)                     if (1 == 2) {
           cout << "Strange ";             cout << "Strange ";
           cout << "Mathematics";          cout << "Mathematics";}
    
    1. Strange Mathematics / Strange Mathematics.
    2. Mathematics / No output.
    3. No output / No output.
  2. Which program part which is correct:
        if (1 == 2)                     if (1 == 2)
           cout << "Strange ";             cout << "Strange ";
                                           cout << "Mathematics";
        else                            else
           cout << "Plain ";               cout << "Plain ";
           cout << "Mathematics";          cout << "Mathematics";
    
    1. Left.
    2. Right.
    3. Both are correct, but left is shorter.
  3. For if ... if ... else ..., does the else belong to the first or second if? (The dots are the conditions and statements or compound statements)
    1. First.
    2. Second.
    3. This is not allowed.
  4. How could you safely reformulate the previous construct so that confusion is not possible?
    1. if ... else if ... else ...
    2. if ... else ... if ... else ...
    3. if ... { if ... else ...}
  5. Which program part produces correct output for any a, b:
        if (a<b || a==b)                 if (a<b && a==b)
           cout << "a is not > b";          cout << "a is not > b";
        else cout << "a > b";            else cout << "a > b";
    
    1. Left.
    2. Right.
    3. Both.
  6. The condition a>b is equivalent to:
    1. b<a.
    2. b<a || b==a.
    3. Both.
  7. The condition a<=b is equivalent to:
    1. b>a || b==a
    2. ! (b<=a)
    3. Neither
  8. The condition a<b is equivalent to:
    1. b>a || b==a
    2. ! (b<=a)
    3. Both.
  9. The expression a<1 || a>3 && a!=0 is equivalent to:
    1. a<1 || (a>3 && a!=0)
    2. (a<1 || a>3) && a!=0
  10. So, is the previous expression true when a is zero?
    1. Yes.
    2. No.
    3. It is too soon to tell.
  11. What does the next program part write:
      for (i=2; i<5; i++) cout << i;
    
    1. 1 2 3 4 5
    2. 2 3 4 5
    3. 2 3 4
    4. 2 4
    5. 2
    6. 5
    7. 6
    8. Nothing.
  12. What does the next program part write:
        for (i=2; i<5; i++); cout << i;
    
    1. 1 2 3 4 5
    2. 2 3 4 5
    3. 2 3 4
    4. 2 4
    5. 2
    6. 5
    7. 6
    8. Nothing.
  13. What does the next program part write:
        for (i=2; i<5; i=i+2) cout << i;
    
    1. 1 2 3 4 5
    2. 2 3 4 5
    3. 2 3 4
    4. 2 4
    5. 2
    6. 5
    7. 6
    8. Nothing.
  14. What does the next program part write:
        for (i=2; i<5; i=i+3) cout << i;
    
    1. 1 2 3 4 5
    2. 2 3 4 5
    3. 2 3 4
    4. 2 4
    5. 2
    6. 5
    7. 6
    8. Nothing.
  15. What does the next program part write:
        for (i=5; i<5; i=i+3) cout << i;
    
    1. 1 2 3 4 5
    2. 2 3 4 5
    3. 2 3 4
    4. 2 4
    5. 2
    6. 5
    7. 6
    8. Nothing.
  16. How many exclamation marks does the next program part write:
        for (i=2; i<5; i--) cout << "!";
    
    1. None.
    2. One.
    3. Infinitely many.
  17. What does the next program part write:
        for (i=2; i>0; i--) cout << i;
    
    1. 0 1 2
    2. 2 1 0
    3. 2 1
    4. 1 0
    5. 1
    6. Nothing.
  18. Can you leave the initialization, test, and increment away from a for loop? If so, what would happen?
    1. No, this will not compile.
    2. Yes, but the statement in the loop will not execute even once.
    3. Yes, but I will lose credit for poor coding.
  19. What is the result of i=0;while (i<2) cout << i++;?
    1. This will not compile.
    2. 0 1 2
    3. 0 1
    4. 1 2
    5. 1
  20. What is the result of while (1==1) cout << '!';?
    1. The cout statement is not executed even once.
    2. It writes a single exclamation mark.
    3. It keeps writing exclamation marks until you manage to kill off the process.
  21. What is the result of while (1) cout << '!';?
    1. This will not compile, since a condition, not a number, is needed within the parentheses of the while.
    2. The cout statement is not executed even once.
    3. It writes a single exclamation mark.
    4. It keeps writing exclamation marks until you manage to kill off the process.
  22. What is the result of while (0) cout << '!';?
    1. This will not compile, since a condition, not a number, is needed within the parentheses of the while.
    2. The cout statement is not executed even once.
    3. It writes a single exclamation mark.
    4. It keeps writing exclamation marks until you manage to kill of the process.

Assessments

Give two strengths of your group:

Give two areas of improvement of your group:

Give two insights obtained about your group:


Give two strengths of the class:

Give two areas of improvement of the class:

Give two insights obtained about the class:


Submission

When all is OK, press the Mail to Instructor button. The Reset button will clear all fields.

Back to activity index