midterm1 - Comp Sci 1MD3 Mid-Term I 2004 Dr. Jacques...

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

View Full Document Right Arrow Icon
Comp Sci 1MD3 Mid-Term I 2004 Dr. Jacques Carette Name: Student No.: Duration : 50 minutes This midterm contains 18 questions on 8 pages. This midterm will be marked out of 50. There are 55 total marks available. Answer the questions in the space provided. Do not separate the pages. Make sure that you do not get stuck on one question; use your time wisely. You should spend roughly 1 minute per mark for each question.
Background image of page 1

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

View Full DocumentRight Arrow Icon
1. Translate the following Pascal code fragment to C. [5] const Len = 10; var J,N: Integer; L: Array[1. .Len] of Integer; begin for J := 1 to Len do L[J] := J*J; N := 1; repeat begin writeln(L[N]); N := N + 1; end; until N > Len; end. 2
Background image of page 2
2. What is the main innovation of 3rd generation programming languages? [1] 3. What is the difference between a declarative statement and an imperative statement (in languages like C and Pascal)? [2] 4. A for loop can always be rewritten as a semantically equivalent while loop. Demonstrate this. Extra credit [2] : show that it can be done with a do-while loop as well. [2] 5. What is the difference between an object and a class? [2] 6. What is a constructor? [1] 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
7. What is the run-time of these code fragments, as a function of
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/26/2011 for the course CS 1md3 taught by Professor Skip during the Spring '11 term at McMaster University.

Page1 / 8

midterm1 - Comp Sci 1MD3 Mid-Term I 2004 Dr. Jacques...

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