0% found this document useful (0 votes)
160 views10 pages

CSC305 Question

Question

Uploaded by

Anas Zakwan
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)
160 views10 pages

CSC305 Question

Question

Uploaded by

Anas Zakwan
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/ 10
CONFIDENTIAL CDISUL 20231CSC305 UNIVERSITI TEKNOLOGI MARA FINAL EXAMINATION COURSE : PROGRAMMING PARADIGMS COURSE CODE : CSC305 EXAMINATION : JULY 2023 TIME 3 HOURS INSTRUCTIONS TO CANDIDATES, 1 This question paper consists of five (5) 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: j) the Question Paper ji) 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 70 printed pages: (© Hak Cipta Universiti Teknologi MARA, CONFIDENTIAL CONFIDENTIAL, 2 CDIJUL 202/CSC305 QUESTION 1 a) il) b) ii) Scheme has predicate functions for lists. Give and describe THREE (3) predicate functions that are available in Scheme. (3 marks) Give the output for each of the following Scheme expressions. 4. (reverse '(u k ti ha i d uitm)) 2. (car ‘(car (HandheldGamingConsoles EReaders Smartphones Tablets LaptopComputers SmartWatches})) (2 marks) Construct a Scheme function to solve each of the following mathematical problems. Bab eo Yen 1 5P4 1, sm2n? 3rs Byz 7 2. sy (4 marks) Given the following functions funct1 and funct2, state the mathematical expressions for each function. (define (funct1 x y) (U # y) 3) ) (© Hak Cipta Universit Teknotogi MARA CONFIDENTIAL, CONFIDENTIAL, 3 CDIJUL 2023/CSC305 (define (funct2 p q) (+(funct1 p q) (sqrt q)) ) (4 marks) 9 i) Analyse the diagram of cuboid M and cube N below which has a volume based ‘on the following formula: i N height a fidth Tenath lene Figure 1 volume = length * width * height The height and the width of cube N is the same as the height and width of cuboid M. By using the formula, write the expression in Scheme to find: 1. The length of the cuboid 2. The differences in volume between the two blocks. (4 marks) iil) Afflicious Cookies provide a variety of cookies for Hari Raya Aidilfitri. The table below shows the price and the delivery date of the cookies. West Malaysia (A) Order completed by 7 ppetvery date and Price |Receive before Hari Raya Aidifftr lapril 17, 2023 (1) [RM35 per container [Receive after Hari Raya Aidiihtrt ‘Apri 18,2023 (2) RM30 per container © Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 4 CDNUL 2023/¢SC305 East Malaysia (B) [Delivery date and Price Receive before Hari Raya Aidilfitri |april 13, 2023 (3) _[RM40 per container IRecelve after Hari Raya Aidiffitri i144, 2028 (4) _RM35 per container Write a Scheme function that displays the information of the delivery date and price according to the table above. (6 marks) QUESTION 2 a) Based on the given facts in Prolog, predict the output for the following queries: [Eapacity LORRY (cargo, 5650). capacity LORRY (container, 4950). jcapacity_ LORRY (trailer, 8850). capacity LORRY (flatbed, 7480). |capacity LORRY (refrigerated, 2050). (6 marks) © 2+ capacity LORRY ( _, 5650). * 2+ capacity_LORRY (Type, 7480). * 2 capacity LORRY (Type, Capacity), Capacity < 5000. © Hak Cipta Universit Teknolog! MARA CONFIDENTIAL CONFIDENTIAL 5 CDIJUL 20281CSC305 b) Consider the following statements: [Maine Coon is a cat. IMikey is a cat. Sherry loves Mikey. Write the facts based on the above statements and create rules for the following statement: + Sherry loves every cat, + Nani loves all Sherry loves. (8 marks) ¢) Based on the following facts: %eroom name, width in feet and length in feet om (living, 18, 20) ‘com (dining, 16, 18) om (kitchen, 12.5, 14.5) oom (master, 12, 16.5) i) Give the output of the following prolog queries: ©? area ( _, _,X), X> 18 ¢ ?- area ( kitchen, A, B) (@ marks) il) Write a rule to caleulate the area of the room. (8 marks) ii) Write a rule to shortlist the room with a length less than 13 and a width less than 15. (4 marks) QUESTION 3 @) Based on the following C program: 6 Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL 6 CDIJUL 20281680305 [Line [Code H___#include 2 int main(voidyt B | inti=3; float b = 2.5; while > Of printf("The sum of the Yd and %.2Fis %.2fin", i, b, i#b) Taye i) Identity ONE (1) syntax error and ONE (1) logical error of the codes and rewrite the correct statements. (2 marks) ') Trace the output of the codes afer the errors are corrected. (3 marks) b) Level of Service (LOS) is one of the typical performance measurements of roundabout. Table 1 summarizes the grading criteria of roundabouts using LOS; “A” being ideal free-flow conditions and “F” being inefficient congested conditions. Table 1: Level of Service (LOS) Criteria [evel of Service (LOS) average Control Delay (s/vehicle) E10 70-15 15-25 P 25-36 P 35-60 P50 THY OF OP wy Sy ‘Write a function of C programming that uses if-else statements that would return LOS for a given Average Control Delay as the input argument. (8 marks) (© Hak Cipta Universit Teknologi MARA CONFIDENTIAL CONFIDENTIAL 7 CDIJUL 20281CSC305 c) Public survey results of the Top three delicacies in Sarawak are listed in the Table 2. Table 2: Top Three Delicacies in Sarawak Name Rating (75) [Price per bow (Ri) [laksa Sarawak 5 }10.50 Kolo Mee x 6.00 i [Pucuk Midin 8 5.00 ) Create a new struct data type in C program to store the data given. (2marks) 1) Declare an array of the new data type created in (i) and store the data in the array. (2marks) li) Due to the increase in raw maierial costs, write a C program segment to increase the prices of the delicacies by 20% of the original price, (2marks) 'V) Write a C program segment display all the data after the price increase. (2marks) QUESTION 4 a) ABC Automobile Service wants to systemize the registration system for their customers. Each customer must provide a name, identification number, and phone number. Meanwhile, the car model, plate number, and owner's information are needed for each car. The owner is the customer, and each customer may have more than one car registered for the service. Identify the TWO (2) objects and their attributes for the system and the relationship between the objects. (6 marks) b) Define a complete subclass for the class Cylinder based on the class diagram below with normal constructor, accessor, and processor calcVolume(), where cylinder volume is Volume = 7h ‘© Hak Cipta Universit! Teknologi MARA CONFIDENTIAL CONFIDENTIAL 8 CDINUL 2028/6305 Circle #radius: double +Cirlce(double) +getRadius():double Cylinder ~ height double +Cylinder(double, double) +getHeight(.double = 55, SalesPrice is CurrPrice * 0.7. december_sales (ItemName, SalesPrice} :- product (ItemName, CurrPrice) , CurrPrice < 55, SalesPrice is CurrPrice * 0.88. (8 marks) END OF QUESTION PAPER © Hk Cipta Universiti Teknologi MARA CONFIDENTIAL

You might also like