Vous êtes sur la page 1sur 12
CONFIDENTIAL = CSIDEC 2013/¢SC425 UNIVERSITI TEKNOLOGI MARA FINAL EXAMINATION COURSE INTRODUCTION TO COMPUTER PROGRAMMING ‘COURSE CODE csc425 EXAMINATION DECEMBER 2013 TIME 3 HOURS INSTRUCTIONS TO CANDIDATES 1 This question paper consists of three (3) parts: PART A (15 Questions) PART B (5 Questions) PART C (2 Questions) 2 ‘Answer ALL questions from all three (3) parts : i) Answer PART A in the Objective Answer Sheet. ii) Answer PART B and C in the Answer Booklet. Start each answer on a new page. 3. Do not bring any material into the examination room unless permission is given by the invigilator. 4 Please check to make sure that this examination pack consists of i) the Question Paper ii) an Answer Booklet — provided by the Faculty iil) an Objective Answer Sheet — provided by the Faculty DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO This question paper consists of 72 printed pages: (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL 2 CSIDEC 2013/¢8C425 PART A (30 MARKS) 100101 10001: 100100 100010 100110 The above instructions are referring to A. machine language B. assembly language C. programming language D. natural language Assembly language uses easy-to-remember instructions called A. assembler B. mnemonics C. algorithm D. pseudocode Which of the following identifiers) is/are LEGAL? |. firstNumber I. first number I, firstNum IV. iNum A. Lonly B. land Il Cc. land Ill D. land iv Which of the following identifier can be used to fix the value of a variable? A. include B. static C. switch D. const ‘What is the result of the following expressions? int x=5/248+ 2.5; A 11 B12 Cc. 12.5 D 12 (© Hak Cipta Universiti Teknologi MARA, CONFIDENTIAL, CONFIDENTIAL 3 CSIDEC 2013/¢8C425 6 Trace the following program segment and determine the output. int x = 0; pOm> 7. Which of the following statements are TRUE in C++? |. Asemicolon is used to terminate the statement. II Commas are used to separate items, example of variables declaration. Ill. Space is used to input separate numbers. IV. Brackets are used to enclose the body of a function or a program segment. A tL B. LU IV Cc. AL MM, IV DM inv 8 Trace the following program segment and determine the output. if (marks ( if (marks < 70) cout<< “\n Good “; else if (marks < 80) cout<< “\n Better “; else if (marks < 90) cout<< “\n Best “; else if (marks <= 100) cout<< “\n Excellent’; ) else cout<< “\n Fail”; ‘What is the result if the mark entered is 59? Good Better Fail Excellent pom (© Hak Cipta Universiti Teknolog! MARA, CONFIDENTIAL, CONFIDENTIAL 4 CSIDEC 2013/CSC425 9. 10. "1. 12. 13, Which of the following structure CANNOT be applied to multiple selections? l if.else Il. switeh...case M. for IV. while A At Boil Cc. itl DMV Which of the following repetition structure is the post test loop? A for B. while C. — do...while D. _switch...case What is the output of the following program segment? for(int x=07x<10;x#+) { if (x 9) x= 07 ) cout<< “\n Hello“; A. Hello B. _The “e110” statements never stop displayed on screen. C. Infinite top Do Which of the following structure can be used to store many data as temporary basis? A. Input and Output (1/0) File B. Array C. Constant D. Variable What is the output of the following C++ statements? int x1) = (3,9,1,0/4,2,6,4,1,3)7 char y[] = (‘a’,"b","c",/d",/e"}; cout<< x[1] << yi4] << x(8)) gel 3d4 9d1 9ea pop> (© Hak Cipta Universiti Teknolog! MARA CONFIDENTIAL, CONFIDENTIAL 5 CSIDEC 2013/¢8C425 14. Which of the following statements are TRUE about function in C++? |. pow () is an example of predefined function. Il. The local variables are also recognized at any function in the program. Ill. The data type of the function should be similar with the value returned by the function. IV. The passing parameter by reference is the value sent to the function is similar with the result returned to the main program. A AAI BMV, cmv DAM ILIV 15. _ Whatis the output of the following program segment? [void output (int, char); lint main() fi joutput (5,/*") 7 return 0; ) void output (int x, char y) (for (inti=0;i> “\n Enter year of birth : “; cin<>destination; cout<< “\n Total adult ticket : “i cin>>adult Ticket; cout<< “\n Total child ticket : "7 cin>>childTicket; if (destination == 1) ticketPrice = 50; else if (destination ticketPrice = 45; else if (destination ticketPrice = 40, else if (destination ticketPrice = 35 3) 4) else ticketPrice totalPrice adultTicket * ticketPrice + childTicket * (ticketPrice/2); cout<< “\n Total price of ticket purchased RM “ <> number; if (number > temp); temp = number; ) cout<< “\n XXXXXXXXXX “ << temp; return 0; ) i) What is the purpose of the above program? ii) Write an appropriate message to replace the XXXXXXXXXX. iil) Rewrite the above program using the white loop structure. (5 marks) QUESTION 5 a) Given the following logical diagram of two arrays named numbers and characters: numbers 915121714 characters i) Write the C++ array declarations for both arrays. ii) Determine the output for the following program segment. cout<< (numbers[3]+numbers[4) <

Vous aimerez peut-être aussi