Computational Physics Laboratory PHZ4151C/PHZ5156C
  Spring 2009

  Class Meetings: HCB 0219, Tuesday and Thursday from 2:00 to 3:15 PM

  Office Hours: Wednesday 4:00 - 5:00 PM or upon appointment

  Course Text: David Yevick, A First Course in Computational Physics and Object-Oriented Programming with C++

5.15 Assignments


(1)   Type in and run the following program computing squares of int numbers.


Example:
> ./program
Insert the number of squares desired: N
Output: 1 4 9 16 ... N2

Source Code




(2)   The Fibonacci series is defined by the relation xm+2 = xm+1 + xm. Starting with x0 = 1 and x1 = 1 write down the first few terms of the series by hand. Modify the above program so that it instead computes the first 10 Fibonacci numbers.


Example:
> ./program
Output: 1 1 2 3 5 8 13 21 34 55

Source Code




(3)   Type in and run the following program, again computing squares of int numbers. This time a function double mySquare is used.


Example:
> ./program
Insert the number of squares desired: N
Output: 1 4 9 16 ... N2

Source Code