SELF-ASSESSMENT of the programming skills

This is a list of programming exercises for SELF-ASSESSMENT of
the programming skills.
We expect students to have enough programming knowledge
(in one programming language of their choice), in order to
solve programming assignments like the ones in the following
examples BEFORE they start their Master study in Wuppertal.

1) Write a program which computes the Fibonacci sequence of numbers
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
through the recurrence relation f_n = f_{n-1} + f_{n-2} and the
starting values f_1=1, f_2=1 .

2) Write a program which computes prime numbers up to a given maximal
number using the iterative algorithm called sieve of Eratosthenes.
The iteration starts with the prime number 2 and marks the multiples
of 2 as not prime. Then it proceeds to the next larger number, which is
not marked and is therefore a prime number. The multiples of it are
marked as not prime and so on.

3) Write a program that calculates and draws histograms. Your program should read in integer numbers between 0 and 20 (reflecting e.g. results from repetitive measurements of a given quantity), count how often which number occurred, and draw horizontal bars of appropriate lengths, like in the following example:
0: 7209 ******************************************
1: 2644 ***************
2: 3987 ***********************
3: 7887 **********************************************
4: 7510 ********************************************
5: 10081 ************************************************************
6: 6692 ***************************************
7: 5997 ***********************************
8: 1131 ******
9: 1940 ***********
10: 6336 *************************************
11: 7831 **********************************************
12: 3718 **********************
13: 3560 *********************
14: 6206 ************************************
15: 1965 ***********
16: 9550 ********************************************************
17: 1044 ******
18: 4615 ***************************
19: 7194 ******************************************
20: 4014 ***********************
The longest bar should consist of 60 asterisks.

zuletzt bearbeitet am: 18.05.2015