CSC1071 Computer Science Diagnostic Quiz

Spring 2004
Herbert J. Bernstein ( )

CSC1071 Computer Science Diagnostic Quiz
Spring 2004

 


This web page is http://www.bernstein-plus-sons.com/.dowling/CSC1071S04/CS_Diagnostic_Quiz.html
Copyright © 2002 -- 2004 Herbert J. Bernstein and other parties. All rights reserved.


This is a computer science diagnistic quiz to be taken on the first day of class. This exam is to help you and your instructor see if you are adequately prepared (or perhaps more than adequately prepared) to take the course for which you have registered. Please do the best that you can on this quiz, but the results will not have any impact on your grade for the course. If you find yourself unable to do most or all of these questions, you should discuss this with the instructor immediately. Unless your problems are likely to respond to intensive tutoring, you may wish to consider taking some other course this semester and taking this course when you have a more solid background. However, do not be concerned if you can do most of the problems but cannot do all of the problems.

This exam must be the results of your own efforts.

The ONLY use you may make of a computer in doing this quiz is to open one browser window to bring you to the online version of the quiz. You may not use a calculator and you may not search for the answers on the web

To avoid disturbing other students, you must remain seated until the end of the examination period.

  <==== Do this AFTER you've answered all the questions

You probably DON'T want to do this ===>  

Please fill in the following information:

Name:


Email:

Computer skills:
Please list the computer languages (C, C++, Java, VB, ... ) and computer systems (MS Windows, Linux, ...) with which you are familiar.

Please answer as many of the following questions as possible on this form (or on a paper copy of this form).

  1. Rewrite the following fragment of code as an equivalent while loop:
    j = 4;
    for ( i = 3; i > 0; i--) {
    j *= i;
    }
    

  2. Assuming appropriate declarations, after execution of the code fragment in question 1, what will be the final value of j?

  3. Briefly explain the relationship between the terms "class" and "object".

  4. Write a java method (or C function) that returns the integer average of two integer arguments.

  5. Write a java method (or C function) that returns the double ratio of two double arguments, and which is protected against dividing by zero.

  6. Write a java method (or C function) that will sort an array of small integers, all known to be in the range 0-255, into ascending order. Do not eliminate duplicates in the array.

  7. For each of the following problems you will be combining fractions by addition, subtraction, multiplication, or division. Your answer must be a fraction reduced to lowest terms. Fill in the answers after the equals sign.
    Addition Subtraction Mutiplication Division  
                     
    1 7 1 7 1 7 1 7
    -- + -- =   -------- -- - -- =   -------- -- * -- =   -------- -- / -- =   --------
    2 16 2 16 2 16 2 16
           
    3 5 3 5 3 5 3 5
    -- +-- = -------- -- --- = -------- -- *-- = -------- -- /-- = --------
    5 3 5 3 5 3 5 3
           
    9 15 9 15 9 15 9 15
    -- +-- = -------- -- --- = -------- -- *-- = -------- -- /-- = --------
    11 17 11 17 11 17 11 17
           
    11 27 11 27 11 27 11 27
    -- +-- = -------- -- --- = -------- -- *-- = -------- -- /-- = --------
    33 47 33 47 33 47 33 47
           

  8. Perform the indicated arithmetic operations. Give the answer as an integer or as a fraction with the smallest possible denominator. Do not give your answer as a decimal fraction. Write each answer on a single line in the indicated box.

    • 4832197 + 6597875 =
    • 368 - 427 =
    • 468 * 827 =
    • 865 / 35 =
    • (43/87) + (29/137) =
    • (11/12) - (23/24) =
    • (19/21) * (7/8) =
    • (11/13) / (18/19) =

  9. Perform the indicated set operations. Give the resulting set for the following operations. Assume all sets are drawn from the universe of non-negative integers. Write your answer after the equals sign.

    • { 1, 3, 5, 7 } ∪ { 2, 4, 6, 8 } = { }
    • { 1, 3, 5, 7 } ∩ { 2, 4, 6, 8 } = { }
    • { 1, 3, 5, 7 } ∩ ¬ { 2, 4, 6, 8 } = { }

  10. The straight-line distance from city A to city B is 312 miles. The straight-line distance from city B to city C is 175 miles. What are the smallest and the largest possible values of the straight-line distance from city A to city C.

    Smallest:
    Largest:

  11. What is the sum of all the natural numbers from 17 to 1005?

  12. What is the sum of all the powers of 2 from 4 to 256?

  13. Consider the following code fragment. What will be the value of m at the end?

    int n,m;
    n = 3;
    m = 5;
    switch(n){
      case 1: m = 7;
              break;
      case 2: m = 8;
              break;
      case 3: m = 9;
      case 4: m = 10;
              break;
      default: m = 11;
    }
    

  14. Explain the meaning of a pointer.

  15. Explain the meaning of a cast.

  16. Explain the meaning of an array.

  17. Explain the meaning of a formal parameter.

  18.   <==== Do this AFTER you've answered all the questions

    You probably DON'T want to do this ===>  

    Revised 2 Feb 2004