Get premium membership and access revision papers, questions with answers as well as video lessons.

Ics2304:Programming Paradigms Question Paper

Ics2304:Programming Paradigms 

Course:Computer Science

Institution: Meru University Of Science And Technology question papers

Exam Year:2012




a. Giving examples where need, explains the following terms as used in programming paradigm.(10 Marks) i. Imperative programming ii. Functional programming iii. Structured programming iv. Event-based v. Declarative programming vi. Automat-based programming vii. Object oriented programming (OOP) viii. Recursion ix. A programming paradigm x. Programming language theory (PLT) b. Explain the benefits of functional programming. (4 Marks) c. Outline the general approach to writing a recursive program. (5 Marks) d. Itemizes the five conditions that must hold for recursion to work. (5 Marks) e. Giving examples differentiate between Linear and Tree Recursion. (4 Marks) f. Outline the software crisis of 1960 in programming. (2 Marks)
QUESTION TWO – 20 MARKS
a. Describe the properties that are key indicators for automata-based programming. (5 Marks) b. Event driven programming is widely used in graphical user interfaces. The design of the toolkits has been criticized for promoting an over-simplified model of event-action, leading programmers to create error
2
prone, difficult to extend and excessively complex application code. Such an approach is fertile ground for bugs for at least three reasons. Identify the reasons. (3 Marks) c. Discuss the five features of functional languages. (12 Marks)
QUESTION THREE – 20 MARKS
a. Distinguish between the following set of terms: (10 Marks) i. Semantics and syntax ii. Static semantics and dynamic semantics iii. Typed and untyped languages iv. Static versus dynamic typing v. Weak and strong typing b. There are many approaches to formal semantics which can be grouped to three major classes. Explain them as listed. (6 Marks) i. Denotational semantics ii. Operational semantics iii. Axiomatic semantics c. Briefly explain prolog programming. (4 Marks)
QUESTION FOUR – 20 MARKS
a. Describe the following with examples: (8 Marks) i. Assignment-free language ii. Declarative languages (non procedural languages iii. A meta-circular iv. A self-interpreter b. Outline the rules for unification in prolog. (3 Marks) c. Consider this prolog program (9 Marks) rainy(vancouver) rainy(sept_iles). snowy(x) :- rainy(x), cold(x) Draw the search tree for the query snowy(C)
The search begins at snowy(C) and finds the rule snowy(X), which then becomes the goal, with C unified to X. Prolog must then establish both rainy(X) and cold (X). It establishes rainy (X) by finding rainy(vancouver), thus (temporarily) unifying X with vancouver. But then it must also find cold(vancouver). Because this fails, prolog backtracks and so it unifies rainy with sep tiles. Going back up the tree, it finds cold(sep tiles) and returns snowy(sept iles).
3
QUESTION FIVE – 20 MARKS
a. Define the term recursion. (2 Marks) b. In order to solve a problem recursively, two conditions must be satisfied. (2 Marks) c. The Fibonacci series has the following form: 0, 1,1,2,3,5,8…. It can be solved recursively fib(n)=fib(n-1) + fib(n-2) i.e the nth fibonacci number is defined as shown b the above expression. Write a function using recursion that calculates the nth recursive number. For instance fib(3) = 1 i.e 1 + 0 and fib(4) = 2 i.e 1 + 1. Tip; The base case: fib(0)=0 and fib(1)=1. Use your function in a main program where you ask the user to a number n and then you output the nth Fibonacci number. (8 Marks)
d. Write a function that converts an input string to uppercase. The argument to the function is a string. The function then returns the string in uppercase. Use your function in a main program where you ask the user to enter a string and then you output the string in uppercase. Do not use the strupr or toupper functions. You have to use a loop. Hint: Characters in C are stored as integers using the American Standard Code for information interchange ( ASCII). The lower case characters are given the integers 97 to 122 where ‘a’=97, ‘b’=98,… The uppercase characters are represented by the integers 65 to 95 where ‘A’=65, ‘B’=66…If you have the statement putchar (97) in your program, then the character ‘a’ is output on the screen. Since characters are integers, then it is possible to do some basic mathematics with them e.g’a’+ 2=99 which is equal to c. (8 Marks)






More Question Papers


Popular Exams



Return to Question Papers