CSC 213 Final, Spring 2008
Notre Dame University–Louaize · Program Design and Data Abstraction II · 1 page
Stuck on a question? A tutor can walk you through it.
More CSC 213 files
- Final with Solution · Spring 2008Final exam · with solutionView
- Final with Solution · Fall 2005Final exam · with solutionView
- Lecture 1 · Spring 2013LabView
- Lecture 1 · Spring 2013LabView
- Problems Assignment 1 · Fall 2012ProblemsView
- Problems Assignment 2 · Fall 2012ProblemsView
- Midterm · Spring 2008ExamView
- Useful File Operator Precedence and Associativity · Fall 2007FileView
Show the text of this final exam
1- Virite a recursive function ibe to print the Fibonacct series of a specilic number n. Each number is generated by the
summation of the previeus two numbers.
The seriesis: O 1 1 2.3 5 8 13 21 34.....
OG al 2, ea 2s (15 pts)
2- Write a class date with 4 fiend function to calculate the day number frum the beginnmg of the year , Write the driver program.
E.g: Input ; 1/5/98 (month=1, day=$ , year= 1998)
Outent: the day number 3 of the year 1998
Input: 210/98
output : the day number 41 of the year 1996, (15 pts)
+) Create a class rational for performing arithmetic with fractions , Write a driver program which contains this class taking into
consideration -
Anoverloaded function addition: 4/342,3 =45,
An overloaded friend function sulitraction ¢ 4/3 -2/3= 2/3.
A friend function nvultiplicution : 4°3*2/3=8/9.
A member function division: 4/3 / 2/34 12-6.
A member fonetion to print 4 s
Use a function reduction to transform Gf3 to 2']_ Ts ita public memberdumgtion or mot? (30 pts)
4- Using overloaded friend functionste read and write an object of the form 09-21 89 30 (20pts}
5- A prime integer is any integer thittis evenly divisible only hy itself and 1. The Sieve of Eratosthencs is a method of finding
prime nunibers. lt operates as follows:
aie itray with all elements initialized to 1. Array elements with prime eubseripts will gemain |. All other array
1-c
elements will eventually set fn 0
2- Starting with subscript 2 { subscript | must be prime}, every time an array clement is found whose value is 1 loop through
the reguainder of the array aid set to Gl every elemmt whose subseripr is a multiple of the subserspt wath the element with the
valugae
Bio: for array subsertpt 2 , all elements beyond 2 in the array that are couliyples of 2 will be sefto 0 (subscripts 4, 6, 8, ...)
Tor array subscript 3, all elements beyond 3 in the array that ere multiples of 3 will he set tot
(subgeripe 6,9,12.15,..)
and so on
When this process is corpleus, the attay ¢lements thet are still set to 0
subsceipls can then be printed. Write an array that uses an array of |
between 1 and 999. Ipnore clemnt 0 of the arney.(20 pts)
| 04441 FE a
: indicate that the gubscrpt is a prime number. These
elemnts te determine and print the prime numbers