0% found this document useful (0 votes)
44 views12 pages

CSC125 128 ITC120 Mac2017

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)
44 views12 pages

CSC125 128 ITC120 Mac2017

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/ 12
CONFIDENTIAL ss CSIMAR 2017/CSC125/128/ITC120 UNIVERSITI TEKNOLOGI MARA FINAL EXAMINATION COURSE : FUNDAMENTALS OF COMPUTER PROBLEM SOLVING COURSE CODE : CSC125/128/ITC120 EXAMINATION : MARCH 2017 TIME : 3HOURS 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 12 printed pages (© Hak Cipta Universiti Teknolog! MARA CONFIDENTIAL CONFIDENTIAL, 2 CSIMAR 2017/CSC125/128/TC120 PART A (20 MARKS) 1 is a program that translates source code of high-level language into machine language one instruction at a time. A. Compiler B. Interpreter C. Assembler D. Source code 2. Select the statement that describes the Maintenance Phase of the Program Development Life Cycle (PDLC). List down or draw the steps involved in sequence to solve the problem. Define the problem to be solved with clear specifications of the problem. Modify or upgrade the existing program or system. Find and eliminate errors by checking the program with all types of data and cases. pOm> 3. _Allof the following statements are valid declaration and initialization of PIE with 3.142 A. fdefine PIE = 3.142; B. #define PIE 3.142 C. const float PIE = 3.142; D. float PIE = 3.142; 4. Choose the CORRECT rules for naming identifiers in C++, i, Identifiers must begin with a letter or underscore. ii. Allletters and digits or underscore may follow the initial letter. iil. Identifiers cannot be reserved words. iv. No different between uppercase and lowercase letters A iii B. i, iii Cc tii D. i, i, ii, iii, iv {© Hak Cipta Universit Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 3 CS/MAR 2017/CSC125/128/TC120 5. Select the relational operator that is INVALID. A < Boos Co D. 6. Analyze the following program fragment and determine the result. int i= 4; if (i te 4 { if (i > 8) iei-4 else isis; } else { ican) ieiea; else iei-7; ub = Ao Bo -3 Cc o8 D8 7. Identify the looping process that checks the test condition at the end of the loop. A. for B. while C. do-while D. no looping process checks the test condition at the end, (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 4 CSIMAR 2017/CSC125/128/ITC120 Determine the output of the program below if the input is 6. int x,y, #1. cin >> y; for (int x { } cout << 2; x++) zt x; 72 720 7200 72000 pomp 9. All of the following functions are for manipulating string data EXCEPT: A. strepy() B. strcat () C. strlen() D. strempr() (© Hak Cipta Universiti Teknologi MARA, CONFIDENTIAL CONFIDENTIAL 5 CSIMAR 2017/CSC125/1281TC120 10. Identify the output of the following program. Winclude void first (int, inte); void second(ints, int); int main() { int q=1; int s = 2; first(q, s); cout << q << " " << 8 << endl; second(q, s); cout << q <<" " cc 8 << endl; } void first (int x, int& y) { int a; a=x x y } void second(inté s, int t) { int b; L 1 2 3 2 A 2 3 90 @ > WERE HHO (© Hak Cipta Universit Teknologi MARA, CONFIDENTIAL CONFIDENTIAL, 6 CSIMAR 2017/CSC125/128/TC120 PART B (50 MARKS) QUESTION 1 a) List TWO (2) types of software and give ONE (1) example for each type. (2 marks) b) Differentiate between flowchart and pseudocode. (4 marks) c) Identify the input, process and output for calculating the surface area of a cyclinder. The formula is given below: surface area in a cylinder = 2nr? + 2nrh (4 marks) QUESTION 2 a) Write a C++ program segment for each of the following statement. i) Declare and initialize GST with 6% and product name with “wat ch’. ji) Prompt user to enter the length in inches and convert to the length in centimeter. (1 inch = 0.0254 meter) (4marks) b) Evaluate the following expressions (Show the steps of solution): i) Y=3*10%5+7/5 ii) Y=52%5*6+(15—5)%4 (4marks) (© Hak Cipta Universiti Teknologi MARA, CONFIDENTIAL, CONFIDENTIAL 7 CSIMAR 2017/CSC125/128/ITC120 QUESTION 3 a) — Given the following flowchart: result = frst number + second number — third number resul= frst number - second number / third number result = frst number * second number ~ (second number, + thie number) i) Write a pseudocode based on the above flowchart. (4marks) ii) Find the output if the inputs are 16, 15, 5, and 2 respectively. (2marks) (© Hak Cipta Universiti Teknologi MARA. CONFIDENTIAL CONFIDENTIAL, 8 CSIMAR 2017/CSC125/128/TC120 b) Fix the errors in the following program fragments: i) The purpose of the program is display pass or fail based on the marks entered. cout << “Enter your marks:"; | if (50 <= marks <= 100) strepy (result, "PASSED") ; else if strepy (result, “FAILED") ; cout << "You result the test” << endl; (4 marks) ji) The normal salary rate is RM 45 per day if the total working days in a month are between 16 to 28 days (inclusive of 16 and 28). Otherwise if the total working days are less than 15 days in a month, the salary rate is half of the normal rate. float rate, salary; int totalWorkingDays; cout << “\n Enter number of working days: cin << totalWorkingDays; if (totalWorkingDays > 15 || totalWorkingDays <= 28) salary = totalWorkingDays * rate; else salary = totalWorkingDays + (rate/2); cout << “\n The salary is RM” << salary; (4 marks) © Hak Cipta Universit Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 9 CSIMAR 2017/CSC125/128/TC120 QUESTION 4 a) Determine the output of the following program segments: i) int a= 12, b= 18, x; cout << acc " "ce bcc" "; while (b != 0) { at by b; ber; } cout << aj (2 marks) ii) while (m != n) { if(m < n) m += Dj else a t= } cout << pce" "ce mcc "ce ny (2 marks) b) Write a C++ program segment based on the following problems: i) Display the highest number among ten positive integer numbers entered by user. Given is the sample output screen: Enter ten positive integer numbers: 34 76 98 564 65 79 2 45 76 54 The highest number is 564 li) Display the following output using a nested for loop. 22 z 3 2 3 (6 marks) @ Hak Cipta Universit Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 10 CSIMAR 2017/CSC125/128/TC120 QUESTION 5 a) Write the function headers for the following problems: i) Function calccomm() will return a sales commission, receive the sales amount and the commission rate. (1 mark) ii) Function displayMonth() will accept the month in number and year, and display the name of the month and the year. (1 mark) ili) Function convertLetter() will input a lowercase letter and return the corresponding uppercase letter through parameter. (1 mark) b) Function circlearea() below will calculate and return the area of a circle: float circleArea(float radius) { float area = 3.142 * radius * radius; return area; } i) Write a main program that reads the radius of two circles. By using the function circleArea () above, calculate the area of the shaded region as shown in the following figure. (5 marks) (© Hak Cipta Universiti Teknologl MARA, CONFIDENTIAL CONFIDENTIAL " CSIMAR 2017/CSC125/128/ITC120 PART C (30 MARKS) QUESTION 1 Cats@Home is a grooming centre for cats that provide a wide range of grooming of shown below: [__AGE (MONTHS) CODE-TYPE OF SERVICES PRICE (RM) | 1- Nail Trimming 15.00 |_Smonths and below | | —>— kitten Bath And Brush 50.00 7 - Nail Trimming 20.00 Above S months 2- Kitten Bath And Brush 60.00 Write a complete C++ program that will be repeated until the user enter ‘N’ to stop. The program will perfom the following tasks: * Get input from user for the following information. > Name of the owner and catikitten. > Age of the catkitten in months > Code of the service type (1 - Nail Trimming, 2 - Cat/Kitten Bath and Brush) © Customers who choose code 2 are given the option to add a medicated shampoo with an additional price of RM 5.00 * Calculate the total fee. The total fee charged is subjected to 6% Government Service Tax. * Display the receipt as shown in the following example: Owner's name cat's name Lola Age (in months): 5 Service Type: Kitten Bath and Brush Fee : RM 55.00 Tax : RM 3.30 Total Fee : RM 58.30 ~Cat@lome-- Khalil aAwang (15 marks) (© Hak Cipta Universit Teknologi MARA CONFIDENTIAL, CONFIDENTIAL QUESTION 2 Below is the conversion table of Malaysian Ringgit to various currer 12 CSIMAR 2017/CSC125/128/ITC120 S. Foreign Currency Units | Country Code_| Malaysian Ringgit | 1.UK Pound A 5.70 | 1 EURO B 4.42 | 11US Dollar Cc 3.94 J ‘Your tasks are to: * Write function calcCurrency () that receives Malaysian Ringgit and will calculate the equivalent amount to all the currencies in the table above. Display the Malaysian Ringgit and all the converted values. The function will return only the US Dollar to the main Program. * Aprofit of 10% will be given if the US Dollar converted is greater than US Dollar 1000.00. Write a function calcProfit () that receives the amount converted in US Dollar in (a) and return the total amount. * Write the main program and show how both functions are called in the main program. The function will be called repeatedly until the user wishes to stop. At the end of the process, display the total amount of Malaysian Ringgit that has been processed. The followi is a sample output screen: Please enter the amount of money? RN 340 RM 340.00 is equivalent to 59.65 Pound 76.92 EURO 86.96 US Dollar Do you wish to continue (¥/N)? y Please enter the amount of money: RM 6500 RM 6500.00 is equivalent to 1140.35 Pound 2470159 EURO 1662.40 US Dollar Us dollar after profit is: 1828.64 US Dollar Do you wish to continue (¥/N)? ‘The total amount of RM that has been processed is: RM 6840.00 (15 marks) END OF QUESTION PAPER (© Hak Cipta Universiti Teknologi MARA, CONFIDENTIAL,

You might also like