CEG220: Introduction to C
Programming for Engineers – I
Section 2
Project 2: Calculating Cube
Roots
Program Background:
By now, most of you have used square roots often in
equations, and have heard of
The algorithm to incrementally approach the cube root of a positive number n with a guess g is:
Guessnew = (2/3) * Guessold + ( (1/3) * (n / (g2) ). Please note the decimal points involved!
Program Description:
Your task is to write pseudo code for this algorithm and implement it as a program. Given a guess as the square root of x, experiment with the number of iterations that is required to get an accurate value for the cube root of x. Is the square root of x a good guess for this algorithm? What might be a better guess (a function of x)? Why?
Program Requirements:
1) Your program must comply with the class programming standard
2) You must submit a hand-written program specification detailing (1) your approach to solving the problem, (2) the algorithm(s) you used, and (3) justifying the data types you have used
Grading Standard:
This project is worth 100 points. Please note that programs that do not compile or do not link will
lose all points related to run-time requirements (examples of run-time
requirements includes but is not limited to correct run output, handling
certain cases adequately, etc.). Grading standard will be followed
strictly:
20 points: Preparatory Requirements
· Compliance with class coding standard (5 points each)
· adequate comments – clear, concise, useful; not excessive
· well-named identifiers
· follows program specification
· hand-written document / program specification (5 points)
· Uses pseudo-code to express the problem and how to solve it
40 points: Run-time Requirements
·
cubert(x) returns
the cube root of x (20 points)
·
uses appropriate style of loop, where
appropriate (5 points)
·
NOTE: if you correctly substantiate why you used
a certain loop in your program specification and/or your code, I will be more
lenient in this category.
·
Handles all cases of n properly (10 points)
·
Uses modular design when appropriate (5 points)
15 points Written Requirements
· questions are answered satisfactorily and substantiated in words and by the results of your program
Due Date:
This project is due on 9/22 at the beginning of class. If
your assignment is late – by 5 minutes or (the maximum) 2 days, the penalty is
30% (see syllabus).
[1] math.h DOES have a function called pow(x, y) which returns xy. You are supposed to calculate cubert(x) using the formula given, and NOT return pow(x, (1.0/3)) = x^1/3 = cubert(x).