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

Info icon This 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.
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern