Midterm1-solution-FA07 - 1 CS421 Fall 2007 Midterm 1...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 CS421 Fall 2007 Midterm 1 Tuesday, October 2, 2007 – corrected 10/3/07 • You have 75 minutes to complete this exam. • This is a closed-book exam.. You are allowed one 3inch by 5 inch card of notes prepared by yourself. This card is not to be shared . All other materials, besides pens, pencils and erasers, are to be away. • Do not share anything with other students. Do not talk to other students. Do not look at another student’s exam. Do not expose your exam to easy viewing by other students. Violation of any of these rules will count as cheating. • If you believe there is an error, or an ambiguous question, you may seek clarification from myself or one of the TAs. You must use a whisper, or write your question out. Speaking out aloud is not allowed. • Including this cover sheet and rules at the end, there are 12 pages to the exam. Please verify that you have all 12 pages. • Please write your name and NetID in the spaces above, and also at the top of every page. Name: NetID: 2 Problems Possible Points Points Earned 1 2 3 4 5 6 7 8 9 10 PreTotal Extra Credit PostTotal 5 9 15 6 10 12 12 8 15 8 100 10 110 3 CS 421 Midterm 1 Name:____________________________________ 1. (5 pts total) Suppose that the following code is input into OCaml: let x = 32;; let make_bigger y = x * y;; let x = 64;; let z = make_bigger 2;; let x = 15.2;; let w = make_bigger 3;; For each of the following, write true or false after each statement. a. (2 pts) z will have a value of 1) 64 True 2) 128 False b. (3 pts) After the declaration of z , 1) The declaration let x = 15.2;; will cause a type error. False 2) The declaration let w = make_bigger 3;; will cause a type error. False 3) The identifier w will have the value 45.6 False 4 CS 421 Midterm 1 Name:____________________________________ 2. (9 pts total) a. (3 pts) Write an OCaml function g:bool -> int -> int that if the Boolean is true returns the double of the integer, and if the Boolean is false returns the square of the integer. Pay attention to the type given....
View Full Document

This homework help was uploaded on 04/21/2008 for the course CS 421 taught by Professor Kamin during the Fall '08 term at University of Illinois at Urbana–Champaign.

Page1 / 12

Midterm1-solution-FA07 - 1 CS421 Fall 2007 Midterm 1...

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

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