I am not exactly sure about the format of the midterm exam but I think you will get a set of programming problems you can choose from and more difficult ones give you more points than simpler ones. However, you probably would like to prepare, so I list a couple of problems you might see in the test. I marked some with *, these will become solvable after the next class. I will continue adding more examples over the next couple of days.

Cheers Arend

Simple:

-count from 1 to 19

-count from 2 to 22, using intervals of 2

-count from 234 backwards to 7

-make a function that counts from S to E using an I interval print letter C in every line next to the number you are currently counting

-make a square size 5×5

-make a function that makes a NxM square, and print the size of it

-sum 100 random numbers

-convert C in F, F in C, inch in cm, cm in inch – all using functions

Medium:

-make Floyds triangle

-count from 1 to N, each time you generate a random number between 0 and the count you are at, print the mean of all numbers

-print a chess board with letters and numbers as indexes next to it

-make 100 random numbers in the range from 1..N, find the lowest and highest

-count from 1 to 100, print the number, but print “tick” instead of the number every third count, print “tock” instead of the number every 5th count, the 15th count will read “ticktock” instead of the number

-make a random number between 0..100 let the computer guess it as well.

-make a function that takes three int parameters A, B, and C. If C is 0 return true if A equal to B, if C is -1 return true if A is bigger than B, if C is 1 return true if A is smaller than B, return false in all other cases

-make a function that takes three int parameters A, B, and C. Compare the values and return the value in the middle

Hard:

-make Floyds triangle backwards, starting with 76 until you hit 0

-simulate a one dimensional random walk, measure the mean number of updates it takes for the random walk to get back to the origin

-make a function that returns the distance between 2 points, each point defined by an X and Y position

-make two arrays called X and Y of size 10 each. X and Y define the coordinate of a point, use this to create 10 random points, and find the point pair with the closest distance