YEAR FOUR SUPPLEMENTARY/SPECIAL EXAMINATION FOR THE DEGREE
OF BACHELOR OF SCIENCE
CCS 3329: PROGRAMMING PARADIGMS
DATE: JULY 2016 TIME: 2 HOURS
INSTRUCTIONS: Answer question one and any other two questions.
QUESTION ONE (30 MARKS)
a) Discuss how the following object-oriented concepts may help a programmer design and implement an application. Illustrate your answer with appropriate examples (10 marks) b) Differentiate between Event Driven programming paradigm and Object Oriented Programming Paradigm (6 marks) c) Describe the term concurrency with reference to software systems and explain why it is desirable for a programming language to provide support for concurrency (6 marks) d) Write a recursive algorithm to display the power of any given positive integer number (4 marks) e) Using relevant examples differentiate between a PREDICATE and a CLAUSE in proglog programming language. (4 marks)
QUESTION TWO (20 MARKS)
a) “A logic program written in the Prolog programming language specifies what a program should do and not how it does it.” With reference to this statement, discuss the differences between a logic programming language and an imperative programming language. (12 marks) Meru University of Science & Technology is ISO 9001:2008 Certified Foundation of Innovations Page 1 b) “In the animal world, carnivores such as lions and leopards hunt and eat herbivores such as zebras and wild beast. Thus some animals are hunters and some are hunted. However there are many exceptions to this rule. Elephants, which are herbivores, are rarely hunted because of their size. Nor are bears, which are not normally meat eaters and therefore basically herbivores. Bears will catch and eat other animals when opportunity arises” (i) Draw a well labeled semantic network to represent the above information. (4 marks) (ii) Write a knowledge base in PROLOG that can be used to represent the above information (4 marks)
QUESTION THREE (20 MARKS)
a) Explain what is meant by the term data abstraction. Use examples to illustrate your answer. (4 marks) b) Explain the terms Functional Programming and Programming Language (6 marks) c) Describe three importance traits that constitute a programming language (6 marks) d) Using relevant examples differentiate between the terms; Syntax and Semantics, of a given language. (4 marks)
QUESTION FOUR (20 MARKS)
a) Describe the following terms: (i) Recursion (ii) Backtracking (4 marks) b) Giving an example of a language, describe a met-circular interpreter (4 marks) c) With reference to the following code, discuss how facts, rules and goals are used in a Prolog program. Explain how this program can be used to find out the possible pairs of grandparent and grandchild? In your answer, briefly explain the role of resolution and unification father(adam, susan). father(adam, bill). father(bill, carl). mother(rose, susan). Meru University of Science & Technology is ISO 9001:2008 Certified Foundation of Innovations Page 2 mother(rose, bill) mother(susan,trudy). parent(X,Y):-mother(X,Y). parent(X,Y):-father(X,Y). grandparent(X,Z):-parent(X,Y), Parent(Y,Z) (12 marks)
QUESTION FIVE (20 MARKS)
a) Discuss the key reasons why it is important to have an international standard for any programming language. (10 marks) b) Write the following statements in symbolic form (5 marks) (i) He is neither handsome nor happy. (ii) To be ugly is to be unhappy. (iii) One is never happy if he Is handsome. (iv) He cannot be both handsome and happy (v) If he is not ugly and happy, then he is handsome. c) An indoor pet is usually a pet that is small. A pet can be a dog or a cat. If it is small and a dog then it is called Simba. Simba has hairy fur. Write a wff(well formed formula) logic program for the above scenario. (5 marks)
Meru University of Science & Technology is ISO 9001:2008 Certified