The American University in Cairo Computer Science Department CSCI 106 Instructor FINAL EXAM Fall 2005 Last Name ID First Name Section No EXAMINATION INSTRUCTIONS Do not turn this page until asked to do so Exam time is 120 minutes Put the answers on the same question sheet do not use any additional papers even for scratch Write your name ID section no in the indicated places Read the exam instructions Read the Academic Integrity Policy Sign the following statement Academic Integrity Policy Cheating in Exams is a violation of the Academic Integrity policy of AUC Whispering talking looking at someone else s paper or copying from any source is considered cheating Any one who does any of these actions or her his answers indicates that she he did any of them will receive a punishment ranging from zero in this exam to failing the course If repeated it may lead to dismissal from AUC I have read the honesty policy and exam instructions and I am presenting this exam as entirely my effort Signature DO NOT USE THIS SECTION Question Points 1 15 2 10 3 20 4 20 5 15 6 20 Total 100 1 Grade Question 1 15 points Tick only one possible answer for each of the following 1 The software that controls and manages the computer resources is a Source program b Loader c Web browser d Operating system 2 The smallest integer number that can be stored in 8 bit unsigned format is a 0 b 128 c 127 d None of the above 3 In binary 1011 11011 a 101000 b 100110 c 110110 d 100101 4 The largest integer number that can be stored in 8 bit two s complement is a 128 b 1127 c 64 d None of the above 5 10E 16 is equivalent to a 9010 10 b 6777 8 c 100001110 2 d None of the above 6 101000011 2 is equivalent to a 503 8 b 503 16 c 554 10 d None of the above 7 15 10 in 8 bit two s complement format is a 110001 b 11110000 c 11110001 d None of the above 8 Von Neumann architecture is a A stored program computer b A web browser c An architecture for RAM d All the above 9 A web browser is a A compiler that translates a source program to an object code b A graphical user interface that allows users to navigate through the web c A software that lets users edits documents d A computer that provides resources to other computers in a network 10 Summing up all even integers is a nonalgorithmic problem because a It s too difficult to compute b It involves infinite number of operations without termination c No machine can do it d The algorithm to do it will very long 2 Question 2 10 points A result of 128 10 was produced in an accumulator of 8 bit structure Give the binary content of the accumulator for each of the following cases 1 The computer is performing its operations in unsigned integer format 2 The computer is performing its operations in two s complement integer format 3 The computer is performing its operations in sign magnitude integer format Question 3 20 points Show the output of each of the following program segments int x 1 y 1 while x 4 y y x cout x setw 3 x y setw 3 y endl int F 6 1 1 const int zero 0 const int one 1 cout setw 3 zero setw 3 F 0 endl cout setw 3 one setw 3 F 1 endl for int k 2 k 6 k F k F k 1 F k 2 cout setw 3 k setw 3 F k endl const int ten 10 int d int n 7856 do d n 10 cout d n ten while n 0 3 int x 1 y 1 while x 3 y y x cout x setw 3 x y setw 3 y endl void nmx int int float void main int n 3 int m 2 float nm 2 757 nmx n m nm cout n setw 3 n endl cout m setw 3 m endl cout setprecision 2 cout result is setw 6 nm endl void nmx int a int b float x a b if a b 0 x 4 75 a else x 4 75 b const int n 6 int A n 4 4 2 5 3 9 bool flag true int k 0 while k n 1 flag if A k A k 1 flag false cout setw 2 k setw 2 A k endl else k if flag cout The list is OK endl 4 Question 4 20 points A graduating student of AUC is awarded an honorary degree according to his her final GPA The honorary degree is granted according to the following rules Final GPA Honorary Degree 3 80 GPA 4 00 Highest Honors 3 60 GPA 3 80 High Honors 3 40 GPA 3 60 Honors 2 00 GPA 3 40 Pass with no Honors Draw a flow chart and write a program in C to input the GPA of a student and print out his her honorary degree Show your analysis draw a flowchart and write down the corresponding program Enforce validation on the input GPA such that it is not less than 2 00 and not greater than 4 00 The Analysis The Flow Chart 5 The Program 6 Question 5 15 points Write a C program based on only two nested loops to produce the following output 7 Question 6 20 points Write a modular program in C a main function and a user defined function binaryToDecimal to perform the following 1 read an integer number containing only 0s and 1s i e a binary integer such as 10011 2 use the function binaryToDecimal that takes as an input the entered integer number of step 1 and computes its decimal equivalent 3 prints out the computed decimal equivalent in appropriate format 4 repeat steps 1 2 and 3 until a 0 zero is entered for the input integer number 8 Good luck 9
View Full Document
Unlocking...