Basic Programming Test
Back to activity index

Basic 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. I/O.
    1. Getting data in and out of the computer
    2. Independent Operations
    3. Interactive Operations
  2. Variables.
    1. Named storage locations
    2. Names for storage locations
    3. Storage locations that can contain anything
  3. Variable types.
    1. Named storage locations
    2. Names for storage locations
    3. Allowable possible contents for storage locations
  4. Precedence.
    1. Order in which statements occur
    2. Order in which computations occur
    3. Order in which compilation occurs

Critical Thinking Questions

  1. What output do you get from the statement:
        cout << "H" << "el" << 'l' << 'o' << endl;
    
    1. Hello
    2. H el l o
    3. "H" << "el" << 'l' << 'o' << endl
  2. What output do you get from the statement:
        cout << "0.500 = " << 0.500 << endl;
    
    1. 0.500 = 0.500
    2. 0.5 = 0.5
    3. 0.500 = 0.5
  3. What is the difference in output between the program segments on the left and on the right:
        cout << "Line 1\nLine 2\n";       cout << "Line 1\n";
                                          cout << "Line 2\n";
    
    1. Everything is printed on the same line by the left segment, on two separate lines for the right.
    2. The left segment single-spaces two lines, the right segment double-spaces them.
    3. There is no difference.
  4. What is the difference in output between the program pieces on the left and on the right:
        cout << "Line 1\n";      cout << "Line 1" << endl
        cout << "Line 2\n";           << "Line 2" << endl;
    
    1. The Left segment single-spaces two lines, the right segment double-spaces them.
    2. There is no difference.
    3. The segment on the right will not compile: the cout is missing.
  5. What should you get from the statement:
        cout << "\a" << "Hi" << "there" << endl;
    
    (Does not work on the PCs, but works on Unix.)
    1. The program writes on the screen \a Hi there
    2. The program writes on the screen \aHithere
    3. The program writes on the screen Hithere and the computer beeps.
  6. Why is the program on the right much better than the one on the left:
        #include <iostream.h>            #include <iostream.h>
        void main(void) {                void main(void) {
           int a;                           int a;
           ...                              int b;
           int b;                           ...
           ...                              ...
           a=1;                             a=1;
           b=3;                             b=3;
           cout << a+b << endl;             cout << a+b << endl;
           ...                              ...
        }                                }
    
    (The dots stand for lots of other statements that are not important.)
    1. All declarations of variables must be at the start.
    2. It is easier for someone to find out about a variable such as b if all declarations are grouped together.
  7. What is obviously wrong (except lack of neatness):
        #include <iostream.h>
        void main(void) {
        int pi;
        ...
        pi = 3.141593;
        ...
        }
    
    1. There should be a semi-colon at the end of the include line.
    2. The assignment statement pi = 3.141593; will crash.
    3. Variable pi is set to 3, not to 3.141593
  8. Why is the program on the left much better than the one on the right:
        #include <iostream.h>           #include <iostream.h>
        void main(void) {               void main(void) {
           float pi = 3.141593;            float pi;
           ....                            ....
           ....                            pi=3.141593
           ....                            ....
           area = pi*r*r                   area = pi*r*r
           ....                            ....
    
    1. It is easier to check whether variable pi has been given the right value.
    2. Computers cannot store many lines of code. You worry about every line.
    3. If we give pi a value early, it will be sure to have received the value by the time we reach the area= statement.
  9. Why is the comment on the left much better than the one on the right:
        #include <iostream.h>           #include <iostream.h>
    
        void main(void) {               void main(void) {
           // Declarations:                // Declarations:
    
           // Define pi:                   float pi = 3.141593; // pi is defined
           float pi = 3.141593;            ....
           ....                            ....
    
    1. You cannot put comments behind statements, they must be on separate lines.
    2. By the time the reader reads the comment in the program on the right, he/she is either mystified or already has figured the statement out by himself.
  10. Which people can benefit from the comments that you put in your program?
    1. You right now.
    2. You, when you try to reuse the program a year from now.
    3. Someone who wants to use your program but does not know exactly what it does.
    4. Someone who wants to modify your program for a similar task.
    5. All of the above.
  11. Can you store arbitrarily large integers in an int? In a long int?
    1. Yes. Yes.
    2. No, there are limitations on the size. Yes.
    3. No. No, but you can store larger integers.
  12. Can you store arbitrarily large real numbers in a float? In a double?
    1. Yes. Yes.
    2. No, there are limitations on the size. Yes.
    3. No. No, but maybe you can store larger real numbers.
  13. Can you store arbitrarily accurate floating point numbers such as $\pi$ or $\sqrt 2$ in a float? In a double?
    1. Yes. Yes.
    2. No, there are limitations on the number of digits behind the first nonzero one that are going to be stored. Yes.
    3. No. No, but you can store more digits.
  14. What do you get from:
        cout << "3*3 = " << 3*3 << endl;
    
    1. 3*3 = 3*3
    2. 9 = 9
    3. 3*3 = 9
  15. What do you get from:
        float a; ...; a=1.5; cout << a << endl;
    
    1. 0
    2. 1
    3. 1.5
  16. What do you get from:
        int a; ...; a=1.5; cout << a << endl;
    
    1. 0
    2. 1
    3. 1.5
  17. What do you get from:
        cout << ".33 = " << 1/3 << endl;
    
    1. .33 = 0
    2. .33 = .33
    3. .33 = .3333333
  18. What do you get from:
        cout << ".33 = " << 1./3 << endl;
    
    1. .33 = 0
    2. .33 = .33
    3. .33 = .3333333
  19. What do you get from:
        cout << "Large: " << 300000*300000 << endl;
    
    1. Large: 300000*300000
    2. Large: 90000000000
    3. Neither
  20. What do you get from:
        cout << "9 = " << 1+2*3 << endl;
    
    1. 9 = 1+2*3
    2. 9 = 9
    3. 9 = 7
  21. What do you get from:
        cout << ".25 = " << 1./2.*2. << endl;
    
    1. .25 = 1./2.*2.
    2. .25 = .25
    3. .25 = 1.
  22. What do you get from:
        cout << "1 = " << 1./2./2. << endl;
    
    1. 1 = 0
    2. 1 = .25
    3. 1 = 1.
  23. What do you get from:
        int i; ...; i=1; cout << i++; cout << i << endl;
    
    1. 11
    2. 1 1
    3. 12
  24. What do you get from:
        int i; ...; i=1; cout << ++i; cout << i << endl;
    
    1. 11
    2. 2 1
    3. 22
  25. What happens during the execution of:
        int i,j; ...; cin >> i >> j;
    
    1. The program prints out ij.
    2. The program prints out the values of variables i and j
    3. The program waits for you to type in ij.
    4. The program waits for you to type in i j.
    5. The program pauses at the cin statement until you enter two integer values from the keyboard. It stores these in variables i and j.

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