*This preview shows
pages
1–4. Sign up to
view the full content.*

This ** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This ** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
**Unformatted text preview: **1 Computer Science Foundation Exam May 5, 2006 Computer Science Section 1A Name: SSN: Q1 KNW Q2 KNW Q3 KNW Q4 ANL,DSN Q5 KNW Q6 DSN Total You have to do all the 6 problems in this section of the exam. Partial credit cannot be given unless all work is shown and is readable. Be complete, yet concise, and above all be neat . Do Your rough work on the last page. 2 1. Do the following problems using summations. All quantities are integers. [ 2 + 2 + 3 + 6 pts ] a) What would be the value of final after the following segment has been executed? final = 0; for ( i= 0 ; i <= 50 ; i++) final += 20; = 50 20 i = 20 ( 50 0 + 1) = 20 (51) = 1020 ( 2 POINTS) AWARD ONLY 1 POINT IF SUMMATION STARTS FROM 1 and ANSWER IS 1000 b) What would be the value of num after the following segment has been executed? total = 0; k = 20; num = 0; for ( i= 1 ; i < 5 ; i++) { for ( j = 1; j <= 30 ; j++) num += 6 * k; total += 3*j 6 ; } num = = = 30 1 4 1 6 j i k num = = 4 1 180 i k = 720 k = 720 (20) = 14400 ( 3 POINTS) AWARD ONLY 1 POINT IF FIRST SUMMATION GOES UPTO 5 AND RESULT IS 18000 3 c) What would be the value of count after the following segment has been executed? count = 0; sum = 0; for ( i= 1 ; i < =5 ;i++) { for ( k = 1; k <= 10 ; k++) count+ = 2 * i; sum+ = 3*k 6 ; } count = = = 10 1 5 1 2 k i i = = 5 1 20 i i AWARD 1 POINT IF THIS IS CORRECT = 20 (5)(6)/2 = 300 AWARD ANOTHER 2 POINTS IF THIS PART IS CORRECT OTHERWISE AWARD ZERO 4...

View Full
Document