Homework 2

Homework 2 - 7 +2 6 +2 3 +2 1 128+64+8+2= 202 d. 10010010 2...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1.) Step Computation What to do next Setup Call the input list L. Call the number of positions in list L, P. Go to step (1) (1) Add up all the variables in list L. Call this sum Z. Continue to step (2) (2) Divide Z by P, and call output B. Output B. STOP 2.) Discussion 2.5 on page 31 >> a=1; >> b=2; >> c=a; >> d=b; >> a=d; >> b=c; >> a; ans: 2 >> b; ans: 1 3.) Discussion 2.6 on page 31-32 a. 1-2-3-4 1-2=-1 -1-3=-4 -4-4=-8 b. 1-2^3-4 2^3=8 1-8=-7 -7-4=-11 c. 1+2*3^4 3^4=81 2*81=162 1+162=163 d. 1/2/3/4 ½=.5 .5/3=.1666666666667 .1666666666667/4=1/24 e. Sqrt(1+2-3+4) 1+2=3 3-3=0 0+4=4 Sqrt(4)=2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
f. 3-5+4/6-8*4^2 4^2=16 4/6=.6666666666667 8*16=128 127.3333333 3-5=-2 -2+.6666666666667=-1.333333333333 -1.333333333333-128=-129. 333333333333 4.) a. 10101011 2 7 +2 5 +2 3 +2 1 +2 0 128+32+8+2+1= 171 b. 01011001 2 6 +2 4 +2 3 +2 0 64+16+8+1= 89 c. 11001010 2
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 7 +2 6 +2 3 +2 1 128+64+8+2= 202 d. 10010010 2 7 +2 4 +2 1 128+16+2= 146 5.) a. c is less than b i. c < b b. a and b are different numbers i. a~=b c. b is equal to zero or is greater than zero i. b>=0 d. a is greater than b but less than c i. b<a<c e. b is less than both c and d i. b<d & b<c f. c is greater than a or b is greater than zero i. c>a | b>a g. b is equal to zero or is greater then zero i. b>=0 h. d is not equal to c but it is equal to b i. d~=c & d==b i. either a is smaller than b or a is smaller than c, but it can not be smaller than both of them i. (a<b & a>=c) | (a<c & a>=b) j. a,b,c and d are all larger than or equal to 100 i. a>=100 & b>=100 & c>=100 &d>=100...
View Full Document

This homework help was uploaded on 04/08/2008 for the course CS 105 taught by Professor Schwarz during the Spring '08 term at Stevens.

Page1 / 3

Homework 2 - 7 +2 6 +2 3 +2 1 128+64+8+2= 202 d. 10010010 2...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online