CCS 2101 Computer Programming CAT 1 Marking Scheme
CCS 2101 Computer Programming CAT 1 Marking Scheme
Question One
i) Explain the role of machine language when writing program [2 marks]
Machine language - directly understood by the computer's CPU. Higher-level programming languages
must be translated into machine language for execution
ii) Discuss the principle of structured programming. [3 Marks]
a. Sequence: Programs are composed of sequences of statements that are executed in
order, one after the other. This is the most basic form of control flow and is present in
all programming languages.
b. Selection: Programs can make decisions based on the evaluation of conditions. This
is usually done using if-else statements or switch statements. The program can
choose between different paths of execution based on the outcome of the conditions.
c. Iteration: Programs can repeat a sequence of statements multiple times. This is
usually done using loops, such as for loops, while loops, or do-while loops. The
program can execute the same sequence of statements multiple times, potentially
with different inputs or outputs each time.
i) Modularity:
Modularity in structured programming refers to the practice of breaking down a program
into smaller, more manageable pieces or modules. Each module is responsible for a
specific task or function within the program. By breaking the program into modules, it
becomes easier to understand, modify, and maintain. Modularity promotes code reuse, as
modules can be reused in different parts of the program or in other programs altogether.
This approach also facilitates team-based development, as different team members can
work on different modules simultaneously.
ii) Algorithm:
An algorithm is a step-by-step procedure or set of rules for solving a problem or
accomplishing a task. In structured programming, algorithms are used to describe the
logical flow of a program. Algorithms are typically expressed in pseudocode or a
programming language, and they are often represented using flowcharts or other visual
aids. Good algorithms are efficient, meaning they accomplish the desired task with
minimal resources (such as time and memory).
iii) Flowchart:
d) A flowchart is a visual representation of the logical flow of a program or algorithm. It
uses symbols and arrows to represent the different steps or processes in the program,
as well as the order in which they are executed. Flowcharts are useful for
understanding the structure of a program, as they provide a high-level overview of
the program's logic. They can also be used to document the program, making it
easier for others to understand and modify. In structured programming, flowcharts
are often used in the design and analysis phases of software development.
Portability – ability of the same software to be used in different computer platforms/ operating systems/
architecture.
Module – Is a software design technique that emphasizes separating the functionality of a program independent
units, such each contains everything necessary to execute only one aspect of the desired functionality.
Module reuse- allows developers to create and use modules as building blocks for larger systems. Parts of
Modules can be reused in different parts of the same systems or in different systems as long as they have clear
interfaces and dependencies.
Question two
Write an algorithm , flowchart, pseudocode and a c program that check whether an integer number
typed is positive or negative.
Step 1: Start
Step 2: get num
Step 3: check if(num>0) print a is positive
Step 4: else num is negative
Step 5: Stop
BEGIN
READ num
IF (num>0) THEN
DISPLAY num is positive
ELSE
DISPLAY num is negative
END IF
END