The American University in Cairo Computer Science Department CSCI 106 Dr kHALIL EXAM III Last Name First Name Spring 2004 ID EXAMINATION INSTRUCTIONS Do not turn this page until asked to do so Exam time is 50 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 honesty policy Sign the following statement HONESTY POLICY Cheating in Exams is a violation of the honesty 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 15 3 20 Total 50 1 Grade Question 1 15 points Show the output of each of the following program segments const int n 6 int L n 2 6 5 4 7 9 bool valu true int k 0 while k n 1 valu if L k L k 1 valu false cout setw 2 k setw 2 L k endl else k if valu cout The list is NOT OK endl Show the output of the following program segment for the following set of data 6 3 9 0 0 19 int n i bool valu bool cont true while cont cin n if n 0 cont false else i 2 valu true while i n valu if n i 0 valu false else i if valu cout n is OK endl int A 10 A 0 1 for int k 1 k 5 k A k k A k 1 cout setw 4 k setw 4 A k endl 2 Question 2 15 points Write a program in C to enter 24 readings of temperature in a day compute the average temperature and count the number of readings that are greater than the average Print the average temperature in two decimal digits and the count with appropriate format 3 Question 3 20 points Write modular program in C to read a pair of integer numbers both of them should be greater than 0 and the second is greater or equal to the first Next the program should determine whether the second integer is the square of the first The program should print out the values of the two integers together with a message notifying whether the second integer is the square of the first or not The program should repeat reading other pairs of integers with the same conditions and doing the same processing The program should terminate when the user enters two equal integer numbers Draw a structure chart and write the code of every function of your program The Structure Chart The Program 4 Good Luck 5
View Full Document
Unlocking...