Question: The algorithm below is used to generate a sequence of numbers. ____A____ ____B____ ___C____ LINE 10 INPUT A, B LINE 20 PRINT A, B LINE

The algorithm below is used to generate a sequence of numbers.

____A____ ____B____ ___C____

LINE 10 INPUT A, B

LINE 20 PRINT A, B

LINE 30 LET C = A + B

LINE 40 PRINT C

LINE 50 LET A = B

LINE 60 LET B = C

LINE 70 IF C < 10 THEN GO TO LINE 30

LINE 80 END

(a) Trace the algorithm when A = 1 and B = 1 in the variables supplied above. +17 points

(b) Suppose that LINE 70 is changed to

IF C < 50 THEN GOTO LINE 30.

Trace and write down the extra values that C now takes. __________ +3 points

(c) A student mistypes LINE 60 as LET C = B. Find the values of A, B and C that the student would get using the amended algorithm in (b). +12 points

____A____ ____B____ ___C____

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!