CSCI 101: Intro to Computer Science
Assignment 5. Due: Mon, Jul 7
Solutions will be posted on Wed, Jul 9
Please save your work in a single text file hw5.txt and upload it on Canvas before midnight of the day above.
- (3x5=15 points)
Convert the following binary numbers to decimal:
- 1111
- 101001
- 110011
- (3x5=15 points)
Convert the following decimal numbers to binary:
- 45
- 258
- 1111
- (2x5=10 points)
- Convert the following HEX number to decimal: CAB
- Write your first name in ASCII code.
- (2x10=20 points)
Write PIPPIN programs to perform the following tasks:
- Swap the contents of cells 5 and 6
- Compute the absolute value |X| of a number stored in a cell X. The
absolute value is defined as follows:
For example, 5 > 0, so |5| = 5.
if X > 0, then |X| = X if X < 0, then |X| = -X
On the other hand, -3 < 0, so |-3| = -(-3) = +3.
- (20 points)
Write a PIPPIN program to compute X=(A+B)*(C+D), assuming A,B,C,D, and
X are stored in cells 100, 101, 102, 103, and 104 respectively.
- (2x10=20 points)
Draw the parse trees for the following algebraic expressions:
- ((x + y) + z) * (x + z)
- 1 + (2*(1 + 2*(1 + x)))
a b \ / + c \ / *