midterm-sol - UNIVERSITY OF TORONTO FACULTY OF APPLIED...

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

View Full Document Right Arrow Icon
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 — Computer Fundamentals Midterm Examination October 28, 2008 12:20 p.m. – 1:50 p.m. Examiners: Jason Anderson, Tom Fairgrieve, Baochun Li Exam Type A: This is a “closed book” examination; no aids are permitted. Calculator Type 4: No calculators or other electronic devices are allowed. All questions are to be answered on the examination paper. If the space provided for a question is insufFcient, you may use the last page or the back of each page to complete your answer. Please indicate clearly on which question(s) you are answering. You must use the C programming language to answer programming questions. The examination has 11 pages, including this one. Circle your lecture section ( one mark deduction if you do not correctly indicate your section): L0101 or L0102 or L0103 or L0104 ±airgrieve (M14) Anderson (M9) ±airgrieve (M11) Li (M11) ±ull Name: Student Number: EC± Login: MARKS 1 2 3 4 5 6 7 8 9 10 11 12 13 Total /3 /3 /3 /3 /4 /4 /8 /8 /8 /14 /14 /14 /14 /100
Background image of page 1

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

View Full DocumentRight Arrow Icon
Question 1 [3 Marks] Given the following C code: int j, sum = 0; for (j = 0; j < 10; j++) sum += j; Rewrite the C statements so that they compute the same quantity but use a while loop instead of a for loop. int j = 0, sum = 0; while (j < 10) { sum += j; j ++; } Question 2 [3 Marks] Write a single C statement that rounds the value of a double variable averageGrade to four dig- its after the decimal point, and stores the result in averageGrade . For example, if averageGrade is 3 . 1415927 , after the statement is executed, averageGrade is 3 . 1416 . You may use any of the mathematical functions discussed in the course. Solution:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

midterm-sol - UNIVERSITY OF TORONTO FACULTY OF APPLIED...

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

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