Tutorial 7.0 (B) 2 Hours

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

TUTORIAL 7.

0 : INTRODUCTION TO PROGRAMMING
L.O : b) Differentiate paradigms of Programming Language : Procedural, Object-oriented and Logic
(2 Hours)

Answer all the questions.

1. Differentiate between Procedural Programming, Object-Oriented Programming and Logic Programming.

Procedural Programming Object-Oriented Programming Logic Programming

Approach problem solving based Approach problem solving based Approach problem solving based
on module or function on the concept of an object that on the idea of answering question
combines both data and the through search for solution from a
function into a single unit knowledge base.
Emphasizes linear steps that Creates classes that are templates Based on axiom, interferences,
provide instructions to computer for creating objects rules and queries to solve a
on how to solve a problem or problem
carry out a task

2. Programming languages are used by programmers to develop software or computerized system.


a) Given these four programming languages – C#, FORTRAN, ALGOL, Prolog and Java, identify
and match the paradigm for each of the programming language.

Paradigm Programming Language


Procedural Programming FORTRAN

Object-Oriented Programming Java, ALGOL, C#

Logic Programming Prolog

3. Two programming paradigms that are usually used by programmers are Procedural Programming and Object
Oriented Programming.

Scenario Programming Paradigm


(i) Ramli writes a step-by-step programming code Procedural Programming
for his drone.
(ii) A software development team wants to build a Object-oriented Programming
portal using Java language. Ahmad is responsible
to write the graphical user interface (GUI) code.
(iii) Natrah wants her programming codes to be Object-oriented Programming
easily integrated with other programmers’ code.
(iv) Kelly plans to write a simple programming code Procedural Programming
to calculate her Body Mass Index (BMI) using C
programming language.
(v) Fathia intends to use reusable code using Object-oriented Programming
objects to develop a Library Management System
for her final year project.
4. Figure 4 (i) and Figure 4 (ii), show types of programming paradigm.

Figure 4 (i)

Figure 4 (ii)
a) Identify the type of programming paradigm in Figure 4(i) and Figure 4(ii). [2 marks]
Figure 4 (i) : Object-oriented programming
Figure 4 (ii) : Procedural programming

b) State the difference of paradigm between Figure 4 (i) and Figure 4 (ii). [2 marks]
Procedural Programming Object-Oriented Programming
Emphasizes linear steps that provide the computer with Creates classes, like template for creating objects.
instructions on how to solve a problem or carry out a task

5. Identify type of programming paradigm and give one (1) example of programming language each in bellow
tables: [6 marks]

Explanation Paradigm Example


Program consists of data and modules/procedures Procedural programming FORTRAN,
that operate on the data. The two are treated as COBOL,
separate entities BASIC, C,
Pascal, Ada
Programming task into objects with each object Object-oriented programming C++, Visual
encapsulating its own data and methods. Basic, Java,
Smalltalk, Ruby,
Python
Programming paradigm uses automated reasoning to Logic programming Prolog, Answer
compute over a set of facts and rules. Program code Set
is written using logic notation Programming
(ASP), Datalog
PAST YEAR QUESTION

PSPM SC015 SESI 2018/2019

1. Identify appropriate paradigm of programming languages for the following statements. [2 marks]
Statement Programming Language Paradigm
Break a big problem into several pieces and work on Object-oriented programming
each piece separately.
Create one thing that has its own data and set of Procedural programming
responsibilities.

PSPM SC015 SESI 2019/2020

2. Compare programming language and programming paradigm. [4 marks]


Programming Language Programming Paradigm
A set of words, abbreviations, and symbols that enables A fundamental style of computer programming that can
a programmer to communicate instructions to a be categorized according to the approach used to solve
computer. a problem

3. List three (3) examples of object oriented programming languages. [3 marks]


=C++, Python, Java

PSPM SC015 SESI 2020/2021

4. List two (2) types of error in programming. [2 marks]


=Syntax error, logical error, run-time error, latent error, compile-time error, semantic error

5. Differentiate between compiler and interpreter. [4 marks]

Compiler Interpreter

A program that translates an entire program A program that translates a program statement line
statement written in high level language into an by line at a time written in high level language
equivalent program in machine language into an equivalent program in machine language

You might also like