| CS 354, version A Fall 2006 | Name:___________________ ID:___________________ Login:_____________________ | |
| Exam 1 | ||
|
No electronic devices may be used while taking this exam. Examples of devices not allowed are calculators, pagers, cell phones, wrist calculators/computers, laptop computers, pocket computers. Each student is allowed one 8.5 by 11 inch sheet of paper with handwritten notes. The notes may be on both sides of the paper. Show all work, and do any/all calculations on the exam. Extra scratch paper may not be used. |
Exam Score Q1 = _____ / 6 Q2 = _____ / 6 Q3 = _____ / 10 Q4 = _____ / 5 Q5 = _____ / 16 Q6 = _____ / 8 Q7 = _____ / 10 Q8 = _____ / 8 Total = _____ / 69 |
Question 1 (6 points total)
PART A (4 points)
Identify the six steps of the instruction fetch and execute cycle
in their proper order.
Question 2 (6 points)
A Unix command line appears as
% stats 10 a1.littleDiagram
argc and argv
as they are given to the stats C program.
Question 3 (10 points)
Write the output from an execution of this C program to the right
of the source code.
#include <stdio.h>
#define MAX 10
/* function addones */
void addones(int *x, int y){
(*x)++;
y++;
}
main()
{
int array[MAX];
int *arrayp;
int a = 100;
int b = 200;
int *ap;
int *bp;
int i; /* loop induction variable */
arrayp = array;
for (i=0; i<MAX; i++) {
*arrayp = a + i;
arrayp++;
}
arrayp = array;
printf("%d, %d\n", array[3], *(array + 3));
ap = &a;
bp = &b;
addones(ap, b);
printf("%d, %d\n", a, b);
return(0);
}
Question 4 (5 points)
Write the C declaration(s) and code for the smallest
code fragment you can think of that
Question 5
PART A (5 points)
Give a base 5 representation for the value 45.26.
Show any repeating digits by placing a bar over those digits that repeat.
PART B (4 points)
What decimal value is represented by the 8-bit,
two's complement representation 11001111?
PART C (4 points)
What is the 8-bit, two's complement representation
for the decimal value 42?
PART D (3 points)
What is the binary for the ASCII character A?
Question 6 (8 points)
Give the IEEE single precision floating point representation
(in hexadecimal) for the decimal value
-13.25.
Question 7 (10 points, 5 points each)
Show your work (where possible) in doing the
following 8-bit, two's complement integer operations.
Give your answer in binary.
For any integer arithmetic operation that causes overflow,
write the word "OVERFLOW" next to the computed answer.
11110000
+ 00011000
-----------
01111100
- 10011100
-----------
Question 8 (8 points)
A character-sized variable (1 byte) contains a two's complement
integer representation.
This variable needs to be added to a 32-bit two's complement
integer representation.
Here are possible operations that might be utilized.