Program Flow and Structure

Program Flow and Structure#

  • Write a purely sequential program which sums over the first 10 natural numbers:

  • Write a sequential program which sums over the first 10 even natural numbers and which uses conditionals:

  • Rewrite the program above using a while loop:

  • Rewrite the program above using a for loop:

  • Write a program which iteratively simulates the upward throwing of a point mass subject to the gravitational acceleration. Find the point when the point mass is at the highest point. To be safe, also introduce a maximum number of iterations after which you stop the iteration in case anything goes wrong: