DOC PREVIEW
CSUN COMP 106 - Homework Solutions

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Jacaranda (Engineering) Room 3333 Mail Code Phone: 818.677.6448E-mail: [email protected] 8348 Fax: 818.677.7062College of Engineering and Computer ScienceComputer Science DepartmentComputer Science 106 Computing in Engineering and ScienceSpring 2006 Class number: 11672 Instructor: Larry CarettoEngineering Building Room 2303 Mail Code Phone: 818.677.6448E-mail: [email protected] 8348 Fax: 818.677.7062Programming Assignment One Comp 106, L. S. Caretto, Fall 2002 Page 3Homework Solutions – February 7, 2006Pages 25-26, Problems 33, 34, and 35Each of these problems consists of a set of statements; you are asked to determine what value would be displayed on the screen as a result of the operations described verbally in those statements. For each problem, the problem statements are shown in bold; the detailed results of each step (and the final answer) are shown to the right of the statements. 33 The variable x starts with the value 0. x = 0The variable y starts with the value 5. y = 5Add 1 to x. x = 1 [new value = old value (0) + 1]Add 1 to y y = 6 [new value = old value (5) + 1]Add x and y, and store the result in y. y = 7 [new y = x (1) + old y (5)]Display the value in y on the screen. The value 7 is displayed on the screen.34 The variable j starts with the value 10. j = 10The variable k starts with the value 2. k = 2The variable L starts with the value 4. L = 4Store the value of j times k in j. j = 20 [new j = old j (10) * k (2)]Store the value of k times L in L. L = 8 [new L = old L (4) * k (2)]Add j and L, and store the result in k. k = 28 [new k = j (20) + L (8)]Display the value in k on the screen. The value 28 is displayed on the screen.35 The variable a starts with the value 1. a = 1The variable b starts with the value 10. b = 10The variable c starts with the value 100. c = 100The variable x starts with the value 0. x = 0Store the value of c times 3 in x. x = 300 [x = c (100) * 3]Add the value of b times 6 to the value already in x. x = 360 [x = old x (300) + 6 times 10]Add the value of a times 5 to the value already in x. x = 365 [x = old x (360) + 5 times 1]Display the value in x on the screen. The value 365 is displayed on the screen.Page 26, Problem 36What is the error in the pseudocode shown below. The code is designed to compute an area by multiplying length by width after these values are input by the user.area = width X lengthDisplay “What is the room’s width?”Input widthDisplay “What is the room’s length?”Input lengthDisplay areaThe error is in the order of the statements. The area calculation is done before the data are entered by the input statements. The “area = width X length” statement must be moved so that it is just after the “Input length” statement and just before the “Display area”


View Full Document

CSUN COMP 106 - Homework Solutions

Download Homework Solutions
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework Solutions and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework Solutions 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?