computer science exam

Home Course Outline Syllabus
Gradebook Submissions
CSCI 101: Intro to Computer Science
Midterm Exam II.     Due: Thu, Jul 31
Please put your work on the server before midnight of the day above (check here for instructions).
You may use books and other materials, but not a human help.
Also, it is not allowed to discuss the problems or solutions with anybody before the exam due.
Save your answers in HTML format in a file named ex2.html
1.    (15 points)   Suppose that your HTML document contains the following form
2.    that takes a number from the left input field and outputs its square in the right field upon clicking the button “compute”. The form is produced by the following HTML:
<form name=”square” action=”#”>
<input type=”text” name=”number”>
<input type=”button” value=”compute” onclick=”process()”>
<input type=”text” name=”result”>
</form>
3.    As it follows from the code, a JavaScript function process() is called if the button is clicked. Write a JavaScript code for this function to accomplish the form functionality stated above.
4.    (15 points)   Assume an array arr consists of the following 5 numbers:
1 2 3 4 5
What numbers will be stored in the array after executing the following JavaScript code:
arr[2]++;
arr[1] += arr[2];
arr[3] = arr[3] / arr[2];
5.    (15 points)   Convert the following number from binary into hexadecimal:
1011010
Hint: one possible way to do it is to convert the number first to decimal and then to hex.
6.    (15 points)   Assume a binary number x is of the form
x = x4x3x2x1x0
That is, x is represented by a binary string of length 5, where x0 … x4 are the bits of this representation.
Let y be the number of the form
y = 1x = 1x4x3x2x1x0
That is, y is obtained from x by adding to its binary representation a 1 on the left.
What is the value of the difference y – x (in decimal)? Explain.
Hint: try several examples. Take a 5-bit binary number x, form the corresponding y, convert x and y into decimal, and compute the difference. Observe the pattern. Provide an explanation.
7.    (20 points)   Write a PIPPIN program that computes z = (a + 1) * (a – 1).
8.    (20 points)   Let a function f(x,y,z) be given by its logic table:
x y z    f(x,y,z)
0 0 0    0
0 0 1    1
0 1 0    0
0 1 1    1
1 0 0    0
1 0 1    0
1 1 0    0
1 1 1    1
9.    Use Paint program to draw a gates diagram for this function. Save your drawing in GIF format in file ex2.gif and invoke it into the file ex2.html
Use only NOT, AND, and OR gates with any number of inputs.
Double check how your design works from the server.

READ ALSO :   Professional Nursing Organizations

PLACE THIS ORDER OR A SIMILAR ORDER WITH US TODAY AND GET AN AMAZING DISCOUNT 🙂