CS1131 Placement Exam


1) Define in a sentence (or two) the following terms:

2) Write a program that reads in three whole numbers (integers) and prints them out in increasing order (i.e., the smallest first).

3) Write a program that reads in a sequence of positive integers and prints out "increasing" if each successive number is greater than the previous one or prints out "not increasing" otherwise. Assume the end of the input numbers occurs when you read a negative number.

4) Write a program that reads in a whole number (integer) and then prints one of the following messages depending on the value of that number:

  • print "infant" if the number is equal to 1
  • print "toddler" if the number is equal to 2 or 3
  • print "preschooler" if the number is equal to 4
  • print "kindergartener" if the number is equal to 5
  • print "elementary age" if the number is equal to 6, 7, 8, 9 or 10
  • print "middle schooler" if the number is equal to 11, 12 or 13
  • print "high schooler" if the number is equal to 14, 15, 16, or 17
  • print "too cool" if the number is equal to 18
  • print "old" if the number is greater than 18

5) Write a program that computes and prints the sum of the odd numbers from 17 up to and including 329 (ie., 17 + 19 + ... + 327 + 329). You must use a loop.

6) Assume you have a 100 element array called XS, with each element containing a real (floating point) number. Assume the array is already declared and values are already stored in the first N elements (N is a variable). Write a short segment of code (not a whole program) to set the variable X to the smallest of those N elements.

7) Write a program that prints the following 45 pairs of numbers:

  • 2 1
  • 2 2
  • 3 1
  • 3 2
  • 3 3
  • 4 1
  • 4 2
  • 4 3
  • 4 4
  • 5 1
  • . .
  • . .
  • 9 7
  • 9 8
  • 9 9

Note that the first numbers go from 1 to 9, and the second numbers start at 1 and go up to the value of the first number (9 times). You must use loops to do this not 45 print statements.

8) Write a segment of code (not a whole program) that sets the elements of a two-dimensional (10 by 10) array called MAP as follows: the top and bottom rows and the left-most and right-most columns contain the value 0, all other elements (the "inside" ones) contain the value 99.

9) Write a program that reads in 50 positive or negative whole numbers (e.g., 5, 946, -32, 0) and prints out only those numbers that are perfect squares (a number N is a perfect square if there is some positive whole number S such that S*S = N). For example, 0,1,4,9,16,25,36, etc. are perfect squares. 2,3,5,6,7,8,10 etc. are not perfect squares. The program MUST use a function (or subroutine, procedure, method, or whatever you call it) to decide if a number is a perfect square. The main program should just read a number, call the function, then print the number if the function indicates it is a perfect square. If you do not know what a function (or subroutine, procedure, method) is, then DO NOT do this problem.

If you do not receive a response within 7 business days, please contact the Computer Science office at (906) 487-2209 to inquire about the status of your test.