Quiz for Chapter 5

Now, let's have a quiz ! If you haven't read the lesson, you had better do it now before starting.

Part I : Theory (Solved in 30 minutes)

  1. Explain the characteristics of all three loop syntaxes in Pascal !
  2. Explain the differences between them !
  3. Suppose the output is :
       1
       2
       3
       4
       5
       6
    
    Write an excerpt using all three syntaxes !
  4. Explain how to nest one syntax to another !

Part II : Practical

In part II, I will give you the sample input and output. You must write an excerpt, using only ONE of the loop syntaxes provided by Pascal. The choice is up to you. As long as they can be run correctly, you get the points. Tip : Before entering this quiz, practise a lot !

A. Easy (Solved in 25 minutes)

1. Input  : 5                          2. Input  : 5
   Output : 1 2 3 4 5 4 3 2 1             Output : 1 2 3 4 5
   Input  : 1                                      1 2 3 4 5
   Output : 1                                      1 2 3 4 5
                                                   1 2 3 4 5
3. Input  : 5                                      1 2 3 4 5
   Output : 1 2 3 4 5                  4. Input  : 5
            2 3 4 5 1                     Output : 1
            3 4 5 1 2                              1 2
            4 5 1 2 3                              1 2 3
            5 1 2 3 4                              1 2 3 4
                                                   1 2 3 4 5

5. Input  : 5                          6. Input  : 5
   Output : 1                             Output : 1 1 1 1 1
            2 2                                    2 2 2 2 2
            3 3 3                                  3 3 3 3 3
            4 4 4 4                                4 4 4 4 4
            5 5 5 5 5                              5 5 5 5 5

Here is the criteria -- If you solve it correctly in :

Time in minutesCategory
<= 3Amazing !
3 < time <= 6Great !
6 < time <= 10Very good !
10 < time <= 15Good !
15 < time <= 20Average
20 < time <= 25Below average
> 25Poor

B. Intermediate (Solved in 30 minutes)

7. Input  : 5                          8. Input  : 5
   Output :        1                      Output : 1 1 1 1 1
                 1 2 1                             1 2 2 2 1
               1 2 3 2 1                           1 2 3 2 1
             1 2 3 4 3 2 1                         1 2 2 2 1
           1 2 3 4 5 4 3 2 1                       1 1 1 1 1
         1 2 3 4 4 4 4 4 3 2 1
       1 2 3 3 3 3 3 3 3 3 3 2 1
     1 2 2 2 2 2 2 2 2 2 2 2 2 2 1
   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  1. Make fibonacci series. If input is n, write all the series up to n numbers :
    Input : 10
    Output : 1 1 2 3 5 8 13 21 34 55
    The first and the second numbers of fibonacci series are 1. The third is the sum of the first and the second. The fourth is the sum of the second and the third. The fifth is the sum of the third and the fourth, so on.
  2. Make a factor tree.
        Input  : 100                    Input  : 1001
        Output :           100          Output :       1001
                          /   \                         /\
                         2     50                      7  143
                               /\                          /\
                              2  25                      11  13
                                 /\     Input  : 5
                                5  5    Output : 5 is a prime !
    
  3. Text animation :
    Input : abcdefghijklmno
    Output : The text will bounce around the screen until a key is pressed.
    For better details, run 11.exe. Note : Original filesize is 4075 bytes. Do not disassemble 11.exe ! It is considered as cheating !!

Here is the criteria -- If you solve it correctly in :

Time in minutesCategory
<= 5Amazing !
5 < time <= 10Great !
10 < time <= 15Very good !
15 < time <= 20Good !
20 < time <= 25Average
25 < time <= 30Below average
> 30Poor

C. (not so) Hard (Solved in 45 minutes)

Create a game just like a space invader (you've got to know that), but in normal text mode (80x25). Use colors as pretty as possible. Normally space invader have a matrix of enemies, but I make allowances to you. You just make only one enemy. If the enemy is destroyed, it just reappears at a different place and the player gains a point. Each players have 3 ships to play. If all ships are used up (shot down) you show Game Over message and ask if the player want to play again. Each enemy ship scores 10. Player got an extra ship when reaches 500 and its multipliers (1000, 1500, 2000,...). Players can only have one shot. Before the fire is out, players can not trigger another shot. The same rule applies for the enemy. Player could only move his/her ship horizon tally (left or right), not vertically or diagonally. The enemy may come closer to the ship after it reaches the edge (of left or right). I mean that the enemy ship go left or right, after it touches the edge, it advances a bit -- just like a normal space invader game. Make it as fancy as possible.

If you made it correctly in :

Time in minutesCategory
<= 15Amazing !
15 < time <= 25Great !
25 < time <= 30Very good !
30 < time <= 35Good !
35 < time <= 40Average
40 < time <= 45Below average
> 45Poor

That's it !


Where to go ?

Back to chapter 5
Advance to chapter 6, about procedures and functions
To lesson 1 contents
My main tutorial homepage
My programming links
Contact me here

By : Roby Joehanes, © 1996, 2000