Professional Documents
Culture Documents
Omputer Rogramming: Session 2: Loops
Omputer Rogramming: Session 2: Loops
Session 2: Loops
Iván Amaya
CONTENTS
WHILE
DO-WHILE
FOR
EXAMPLES
Cond
Process
Process
Cond
Process
Create a program that prints the numbers from 0 to 10. Use different loop
structures
Create a program that divides a given even number into two, until the
number becomes one. Print each number and the total amount of divisions.
For loop
COMPUTER PROGRAMMING – SESSION 2 IVÁN MAURICIO AMAYA CONTRERAS 10
EXAMPLES
You are thinking on opening an account at a bank. There are several
options available and, thus, you would like to have a means of quickly
assessing which one is the best option for you. Specifically, you would like
to know how many months would it take to double an initial investment C,
at a given interest rate. Create a program to sort this problem out, reporting
the value after each month has passed.
After each bounce, a ball losses part of its energy. Assuming an initial
height (H), create a program that simulates each bounce, reporting the
number of bounces until the ball is unable to reach a height equal to one
fifth of the initial value.