CPSC170A
Fundamentals of Computer Science II

Lab 16

Review

Titius-Bode

Write the C++ function titius_bode(int i) that uses recursion to compute the value \(d_i\) in the sequence defined by the following equations:

\[b_1 = 1\] \[b_2 = 3\] \[b_i = b_{i - 1} * 2\] \[d_i = \frac{4 + b_i}{10}\]


Circle Struct

Create a C++ structure Circle that represents a two-dimensional circle. The structure should have functions to support the following usage:

Circle circle(3.0);
std::cout << "area of circle with radius 3 is " << circle.area() << std::endl;