Correct my lab c++

Anonymous
timer Asked: Apr 15th, 2017

Question description

hello i have lab c++ program i need to get it correct and this the text answer :

Lesson 18-2



Ex1:



po1.cpp

/* 2/4 points */

/* You did not record your output. */



Ex2:



factorial.cpp

/* 0/4 points */

/* Your program does not calculate the fibonacci numbers. Your program

does not work because it contains an error that causes the recursion to

go past 0 and then recurse inifinitely after it. If you would like a

more thorough explanation you can ask me or Dr. Lee about this. In

addition, this and the next exercise are about fibonacci numbers, not

factorials. */



Ex3:



factorial2.cpp

/* 2/4 points */

/* You did not record your output. */



Ex4:



I like used iterative version, because it would compute intermediate values only one time.

The iterative version will compute every value ,

for example Fib(2) and Fib(3) only one time, and it is more efficient.

/* 4/4 points */





---------



Lesson 18-3





Ex1:



recursive.cpp

/* 2/4 points */

/* While your program does recursively print out the elements in an

array with limit values, your porgram does not fulfill all the necessary

requirements. Your program was supposed to obtain the values for the

array from the file "recursive". You program initializes all the values

of the array, instead of filling in only the exact amount needed. In

addition, you had the user set the limit, instead of setting the limit

based on how many values were read in from the file. */



Ex2:



recursive2.cpp

/* 0/4 points */

/* Code does not compile. */



Ex3:



recursive3.cpp

/* 0/4 points */

/* Code does not compile. */



Ex4:



The recursion is well-used. With recursion, we get to the last element

before starting printing the elements. We dont need to use another data

structure to complete this task.

If we dont use recursion, we would need to store the elements of the

list into a stack, and then print the elements of the stack.

/* 2/4 points */

/* You did not answer both parts of the question. You were supposed to

say whether both situations were good uses of recursion. You only

touched on the use of recursion in the first situation. */



/* Ex 5 0/4 points */

/* No code or answer detected for this exercise. */

/* Ex 6 0/4 points */

/* No code or answer detected for this exercise. */





---------



Lesson 18-4





Ex1-2:



sumtest.cpp



The two errors was data >> tempValue; and missing reutern.

i dealet // data >> tempValue;

and i add return 0 in the end.

/* 4/4 points */

/* 6/6 points */

/* You should have created the file int.dat. If you did not have a

working input file, then you could not know whether or not the program

was actually functioning correctly. */

Tutor Answer

(Top Tutor) Studypool Tutor
School: Duke University
Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors