CMPT120 – Introduction to Computing Science and Programming I
Instructor: Muntaseer Salahuddin
Midterm Exam: Spring 2013
Total Points: 40
Total Time: 90 minutes
Last Name: _______________________________________________
First Name: _______________________________________________
English Name (if applicable):_________________________________
Student ID: _______________________________________________
Signature (Bank Signature): __________________________________
• Please fill in the information above very clearly.
• Do not open this test booklet until instructed to do so.
• Show all your workings. Failure to show workings will result in a 0 for that question,
regardless if the answer is correct.
• Please write all your answers in this booklet. You will not be given any extra
pages to write your answers. There is one empty page at the end in case you need
to make draft notes.
• There is partial marking where appropriate, so answer as much as you can.
• There are 5 questions in total.
• Good luck! 1. Perform -4)10- 60)10in a 7 bit binary 2’s complement system. Also indicate
whether this is a case of OVERFLOW or NO OVERFLOW and mention why.
1111100 = -4)
1000100 = -60) 10
1000000 = -64) [special case]
This is a case of IGNORE CARRY as the carry-in to the MSB (1) is the same as the
carry-out of the MSB (1)
2. Given that we are working in a 6 bit 2's complement system, state how many
integers may be represented by this system as well the largest and smallest
positive and negative integers that may be represented by this system.
2 = 256 so 256 numbers may be represented.
Half positive and half negative so 128 positive and 128 negative.
Largest positive: +127
Smallest positive: +0
Largest negative: -1
Smallest negative: -128
2 3. Draw a flow-chart that takes an input positive integer N and outputs all its factors
and also the count of number of factors it has.
For example, if N=10 then its factors are 1,2,5 and it has 3 factors. If
N=12 then its factors are 1,2,3,4,6 and it has 5 factors.