Programming 1 Essay

Submitted By cherishye
Words: 1372
Pages: 6

|Course: | |ITECH1000/5000 |
| | |PROGRAMMING 1 |
| | | |
|Date: | |Version: June 2012 |
| | | |
|Reading Commences: | | |
| | | |
|Writing Commences: | |10 minutes after reading commences |
| | | |
|Duration: | |2 hours |
| | | |
|Location Course Coordinator: | | |
| | | |
|Total marks: | |50 marks |

Instructions to candidates:

1. Print your name and student number on the Examination Paper.

2. Attempt ALL questions, answering in the spaces provided.

3. Do not detach any portion of the examination paper.

4. Begin writing, as indicated, after the reading time has ended.

Materials allowed (in addition to normal writing materials): Nil

DO NOT REMOVE ANY PART OF THIS EXAM PAPER FROM THE EXAMINATION ROOM

|Student Name: | | |
| | | |
|Student ID: | | |

MODEL ANSWERS
Q1. a) Using the following successive assignment statements in a segment of code, write down the values of variables x & y at the completion of each line of code. Use ‘undefined’ where a variable is undefined.
|code |value of x |value of y |
|y = 3 |undefined |3 |
|x = 2 |2 |3 |
|x = x + y |5 |3 |
|y = y - 1 |5 |2 |

b) Draw a diagram of the activation stack after all the assignment statements have been executed. x 5 y 2 main() --- [2 + 2 = 4 marks]

Q2. Inspect the following code segment.

number = 0 # line 1 max = 0 # line 2 while number > -999: # line 3 number = input (“Enter a number: “) # line 4 - numbers to be entered are in the table