The American University in Cairo Computer Science Department CSCI 106 05 EXAM II Dr KHALIL Fall 2004 Last Name ID First Name Form I Examination Instructions Do not turn this page until asked to do so Exam time is 75 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 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 25 2 25 3 25 4 25 Total 100 Grade 1 Question 1 25 points In the commencement 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 3 80 GPA 4 00 3 60 GPA 3 80 3 40 GPA 3 60 2 00 GPA 3 40 Honorary Degree Highest Honors High Honors Honors Pass with no Honors Draw a flow chart and write a program in C to input the GPA of a student the GPA is not less than 2 00 and not greater than 4 00 and print out his her honorary degree Show the three phases of software development the analysis design and implementation Implement your solution in C once using nested if structure and second using switch structure You have to validate the input to the program The Analysis Flow Chart 2 Program Using nested if structure Program Using switch structure 3 Question 2 25 points Show the output of each of the following program segments int a 2 b 1 c 0 while a 5 b b a c a cout b setw 3 b c setw 3 c n cout a setw 3 a n r 1 while r 4 c 3 while c 10 valu r c cout setw 3 valu c 4 cout endl r 2 const int ten 10 int valu 0 int d int n 11001 int b 1 do d n ten valu valu d b b 2 n ten while n 0 cout The final value is setw 4 valu endl int a 2 b 1 c 0 while a 2 a 2 b b a c a cout b setw 3 b c setw 3 c n cout a setw 3 a n 4 Question 3 15 points Using nested loops write a program segment that produces the following output 1 123 12345 1234567 123456789 5 Question 4 25 points Write a program in C to input a list of n 50 at most integer numbers each of which is in the range 1 to 100 The program should print out one of the following three messages The list is sorted in an ascending order if the list is sorted ascendingly or The list is sorted in a descending order if the list is sorted descendingly or The list is not sorted at all if the list is not sorted either ascendingly or descendingly You have to validate every input to the program 6 Good Luck 7
View Full Document
Unlocking...