0% found this document useful (0 votes)
56 views

CSC128 (Dec 2018) Question

csc questions

Uploaded by

adam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
56 views

CSC128 (Dec 2018) Question

csc questions

Uploaded by

adam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 11
CONFIDENTIAL, CSIDEC 2018/¢8C128 UNIVERSITI TEKNOLOGI MARA FINAL EXAMINATION COURSE : FUNDAMENTALS OF COMPUTER PROBLEM SOLVING COURSE CODE : CSC128 EXAMINATION : DECEMBER 2018 TIME : 3 HOURS INSTRUCTIONS TO CANDIDATES 1 This question paper consists of three (3) parts: PART A (10 Questions) PART B (5 Questions) PART C (2 Questions) 2. Answer ALL questions 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 invigitator. 4 Please check to make sure that this examination pack consists of : i) the Question Paper ii) an Answer Booklet — provided by the Faculty 5 Answer ALL questions in English, DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO This examination paper consists of 17 printed pages (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 2 CSIDEC 2018/¢SC128 PART A (20 MARKS) 1. The FIRST step in Program Development Life Cycle (PDLC) is to plan the algorithm analyze the problem desk check the algorithm code the algorithm pom> 2. Syntax errors in C++ ‘A. can cause subtle error when the application runs B. are ignored by the computer C. prevent the application from compiling correctly D. are detected after the application has been completed 3. Which of the following identifies the purpose of else ina if statement? ‘A. It identifies the value being compared. B. It terminates the i£ statement. C. It causes the compiler to skip the if statement. D. Itexecutes only if the test value does not equal any of the other cases in the if. 4. Which of the following is valid identifier in C++? A. bool B. HotelTransylvania3 C. Hour Work D. 2ndvalue 5. Whatis the result of the following expression if data type of y is int ? y=4+(3*(8+6)-3)/2 23 29 23.5 175 pop> 6. Which of the following statements is FALSE? A. A pre-test loop tests the condition prior to executing the loop body. B. Itis an error to use the for statement in awhile loop. C. Itis possible that the statements ina while loop are never executed, D. A loop that continues to execute endlessly is called an infinite loop. © Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL 3 CSIDEC 2018/¢SC128 7. How many times the loop will be executed? for (int y = 0; y < 8; y= y+ 3) cout << “Avengers: Infinity War” << endl; 8. What is the output of the following C++ program segment? int value = 0, total = 0; do { total = total + value; value = value + 2; } while (value < 5); cout << total; pom> 9. Which of the following function definition DOES NOT have any syntax error(s)? A. int CalSquare(int x) { int x; return (x * x); } B. double calcResult (float n) { return (2 * n); } C. void calcArea(int r) double answer; return answer = 3.142 * x * r; } D. int printvalue(int x) { } cout << x; © Hak Cipta Universiti Teknolog! MARA CONFIDENTIAL CONFIDENTIAL 4 CSIDEC 2018/¢8C128 10. Which of the following statement is INCORRECT? A. Itis an error to use the return statement in the function with reference parameter. B. Only one value can be retumed to the calling function using the return statement. C. The type of the value returned by the function is a void when no value is returned, D. A function must be declared before it can be used. © Hak Cipta Universiti Teknologi MARA CONFIDENTIAL, CONFIDENTIAL, 5 CSIDEC 2018/¢8C128 PART B (50 MARKS) QUESTION 4 a) Evaluate the following logical expression: 13 13) && ((3 > 5) |] (13 < 10))) (2 marks) b) Identify input, process and output for a program to calculate and print the area of a square and the shaded region. (Hint: areaC = trr?, 1 = 3.142) side + side (4marks) c) Write a C++ program segment based on the following statements. Declare three variables called n1, n2, n3 as integer and one variable called average as double. Prompt the user to input 3 values and store them into n1, n2 and n3. Calculate the average of the 3 values entered. Then, print the input values obtained and the average. (4 marks) (© Hak Cipta Universiti Teknolog! MARA, CONFIDENTIAL CONFIDENTIAL 6 CSIDEC 2018/C8C128 QUESTION 2 a) Determine the output for the following C++ expressions : i) cout << 55% 4+ 2-6/4 + pow (3, 2) << endl; (2marks) ii) cout << 2 ~ (5/7) +3 + (4% 5) + (1- (3 / 2) * 3) >amount ; veturn amount; } float getDiscount (float amount) { float discount; discount = 0.25 * amount; return discount; Write a main () program that requires a user to input telephone bill amount using function getBillamount () and get the discount amount of the bill amount using function getDiscount (). Then calculate and display the bill amount after discount. (6 marks) (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL PART C (30 MARKS} QUESTION 1 ) 10 CSIDEC 2018/¢8C128 Kuching Digital Community Run is going to be held in the next coming holiday season. The following table shows the details: Category) [Citizen | Cost Distance! |) Time Limit |_Malaysian RM60_ Adults Ole TEDaD 5km 1 hour a Malaysian | __ RM20 3km 45 min _ Others USD15 In order to run the program smoothly, the organizer is hiring you as a programmer to develop ‘a computer program. In developing the program, you should consider each of the following: ‘+ The user's name, citizen, the number for each category, and distance should be entered following the respective INPUT statements. The program will repeat until the system administrator input is *N or n°. ‘* Calculate the total payment for each user and the grand total for all users. [Note: USD 1 = RM4] * Count the number of adults and kids involved in the whole program. * Write a complete C++ program and for each user generate a receipt using the format in the following exampl NAME CITIZEN NO. OF ADULT NO. OF KIDS PAYMENT ADULT KIDS TOTAL PAYMENT THANK YOU - Total number of kids (© Hak Cipta Universiti Teknologi MARA KUCHING DIGITAL COMMUNITY RUN 2078 AMIN BIN AMINUDDIN MALAYSIAN 2 2 RM120.00 RM80.00 RM200.00 RY MUCH Total number of adults : XX XX Grand Total = RM XXXX.XX (15 marks) CONFIDENTIAL, CONFIDENTIAL, " CSIDEC 2018/CSC128 QUESTION 2 Below is the car rental rates table of Kenyalang Car Rental Sdn. Bhd. Code Car Type Rental Rate per Day (RM) Viva 75.00 Tr Myvi 90.00 Proton 110.00 As a programmer, you are required to write a C+ program based on the following tasks ‘+ Write function carType () that receives car code and displays the car type. This function return car rental rate to the main program. © Adiscount of 10% will be given if a customer rents a car more than 3 days. Write function getDiscount () that receives number of days and car rental rate. The function will calculate and return the discount price. + Write a main) program and show how both functions are called in the main program. In the main program, customer needs to input name, address, telephone number, number of days and car code. The output of the program shown as below. KENYALANG CAR RENTAL Please enter customer name : Jelita Ali Please enter address : Kampung Setia Please enter telephone number : 0112345456 Please enter number of days Please enter car code (V - Viva, M-Myvi, P-Proton) : P Car Type: Proton PAYMENT INFO CAR RENTAL Customer namé : Jelita Ali Address : Kampung Setia Telephone number : 0112345456 Number of days : 3 Car code : P Rental Rate : RM 110 Rental after discount :RM 0 Price after discount : RM 330 (15 marks) END OF QUESTION PAPER (© Hak Cipta Universit Teknologi MARA CONFIDENTIAL

You might also like