1.
Structured Programming Fundamentals
Definition: Structured programming involves breaking down large programs
into smaller, manageable chunks called modules.
This makes the code easier to understand and maintain.
Structured programming is a programming paradigm that emphasizes
breaking down a program into smaller, manageable modules or functions.
Control Structures: Structured programming relies on three fundamental
control structures:
o Sequence: Executing instructions in a specific order.
o Selection: Choosing which code to execute based on a condition (e.g.,
if-else statements).
o Iteration: Repeating a block of code (e.g., loops).
THE PRINCIPLES OF STRUCTURED PROGRAMMING
Modularity (Modular Design)
Definition: Modularity is the process of splitting a program into smaller,
independent sections called modules or chunks. Each module is designed to
perform a specific function or task.
Explanation: This principle promotes breaking down a complex problem
into simpler, more manageable sub-problems, allowing for a systematic
approach to program design. This approach helps in dealing with the system
as a whole by simplifying its components.
Rules for Modularization:
o Each module should contain a single program function.
o The maximum number of instructions within a module should
generally not exceed 100.
o Each module should have a single entry and a single exit point.
Advantages of Modules:
o Reduced Complexity: Breaking a program into smaller modules
reduces the overall complexity of the system.
o Easier Testing and Debugging: Individual modules can be tested in
isolation, making it easier to track and remove errors.
o Simplified Maintenance and Modification: Changes or amendments
made to a single module do not affect the rest of the program,
reducing the effort required for program modification.
o Code Reusability: Modules can be reused in different parts of the
same program or in other programs, saving development time and
effort. This also facilitates the creation of libraries for frequently used
routines.
o Improved Readability and Documentation: Modules can be named
descriptively, which assists in documentation and makes the code
easier to understand.
Control Structures
Definition: Control structures are fundamental programming constructs that
dictate the flow of execution within a program. Structured programming
emphasizes the use of a few simple control structures to solve problems.
Explanation: These structures provide a logical and predictable flow,
eliminating the need for unstructured "goto" statements that can lead to
"spaghetti code" and make programs difficult to follow.
Types of Control Structures:
o Sequence: Instructions are executed one after another in the order
they appear in the code.
o Selection (Decision): This structure allows the program to make
decisions and execute different blocks of code based on whether a
condition is true or false. Examples include IF, IF...ELSE, NESTED
IF...ELSE, and SWITCH CASE statements.
Condition: The decision is based on a Boolean expression that
returns either true or false.
o Iteration (Looping): This structure allows a block of statements to be
repeated a specific number of times or until a certain condition is met.
Examples include WHILE...LOOP, DO...WHILE LOOP, and
FOR...LOOP.
Stepwise Refinement (Top-Down Design)
Definition: This approach involves breaking down a large program into its
major tasks or components, and then successively subdividing each major
component into smaller, simpler, and more manageable components until
sufficient detail is achieved for coding.
Explanation: It starts with a high-level outline of the program, showing the
main tasks and their execution order. This process continues until the
problem is broken down into small, solvable units. This is a methodical way
to design a program by providing a complete definition at each level of
complexity.
Single Entry and Exit Points
Definition: Each module or control structure should have only one entry
point (where execution begins) and one exit point (where execution leaves).
Explanation: This principle ensures a predictable flow of control, making
the program easier to understand, test, and debug, as the path of execution is
clear and unambiguous.
2. Program Design Tools
1. Algorithm
Definition: An algorithm is a series of step-by-step instructions that produce
a solution to a problem.
Explanation: It serves as the blueprint for a program, enabling the
programmer to devise models of expected programs during the design phase.
These models illustrate the flow of events and data throughout the entire
program, from input to output. Choosing the appropriate algorithm depends
on the specific problem at hand.
2. Flowchart
Definition: A flowchart is a pictorial representation of a program's logic.
Explanation: It uses standardized symbols to depict different operations and
the flow of control within a program.
o Symbols Used:
Start & Stop: Oval shapes indicate the beginning and end of a
program.
Input & Output: Parallelograms represent operations where
data is entered into or displayed from the program.
Decision/Test: Diamond shapes signify a point where a
decision is made, leading to different paths based on a condition
(true or false).
Process: Rectangles denote a specific action or calculation
within the program.
Connectors: Small circles are used to connect different parts of
the flowchart, especially when it spans multiple pages.
Flow Direction: Arrows indicate the direction of the program's
flow.
o Advantages:
Pictorial and Easy to Understand: Being a visual tool,
flowcharts are generally easy to comprehend.
Standardized Symbols: The use of standard symbols ensures
consistency and ease of enforcement.
Two-Dimensional Tool: It allows for a comprehensive
overview of the program logic.
Information Can Be Attended: It helps in organizing and
presenting information clearly.
o Disadvantages:
Tiresome to Create: Developing complex flowcharts can be
time-consuming and tedious.
No Direct Relationship with Code: There isn't a direct one-to-
one correspondence between flowchart symbols and
programming code, which can make translation challenging.
3. Structured Chart
Definition: Structured charts show the overall framework of a program, with
each level providing progressively more detail. They are used to depict the
hierarchical relationships between program modules.
Explanation: These charts visually break down a program into its
constituent modules and illustrate how these modules interact. They are
often used in conjunction with other design tools like pseudocode and
flowcharts to elaborate on process or procedure logic.
4. Pseudocode / Structured English
Definition: Pseudocode, also known as structured English, aims to provide
programmers with clear and unambiguous process specifications.
Explanation: It is typically preceded by a hierarchy of modules defined in
structured charts. The process logic in pseudocode is expressed as a
combination of sequences of events, decisions that need to be implemented,
and actions that may have to be repeated. It allows for describing algorithms
in a human-readable format without strict syntax rules, making it easier to
plan program logic before actual coding.
3. Program Development Cycle
1. Problem Understanding / Problem Definition
Definition: This initial phase involves clearly defining the problem that the
program is intended to solve. It includes understanding the requirements,
objectives, and constraints of the project.
Explanation: During this stage, the programmer or development team
works to thoroughly grasp what the user needs and what the program should
accomplish. This may involve gathering information through interviews,
surveys, and analysis of existing systems. A well-defined problem statement
is crucial for guiding the entire development process.
2. Planning Methods of Solution / Program Design
Definition: In this phase, the detailed plan for solving the problem is
formulated. This involves outlining the program's structure, algorithms, and
data flow.
Explanation: This stage is critical for creating a robust and efficient
program. It often involves using various program design tools such as:
o Algorithms: Step-by-step procedures to solve the problem.
o Flowcharts: Graphical representations of the program's logic and
flow.
o Pseudocode: A high-level, language-independent description of the
program's logic.
o Structure Charts: Diagrams showing the hierarchy and relationships
between different modules of the program. The output of this phase is
a detailed design document that guides the coding process.
3. Developing the Methods (using suitable aids)
Definition: This stage involves refining the planned solution, possibly
through iterations and using appropriate tools and techniques to ensure its
feasibility and effectiveness.
Explanation: While closely related to planning, this phase might involve
more detailed breakdowns and considerations of specific implementation
strategies. It could involve prototyping or creating more elaborate design
specifications before moving to the actual coding. This ensures that the
chosen methods are practical and align with the problem's requirements.
4. Coding / Implementation
Definition: This is the stage where the program design is translated into
actual programming code using a chosen programming language.
Explanation: Programmers write the source code based on the algorithms,
flowcharts, and pseudocode developed in the design phase. Adherence to
structured programming principles is vital during this stage to produce clear,
maintainable, and efficient code.
5. Testing
Definition: Testing is the process of evaluating the program to identify any
errors (bugs) and ensure that it functions as intended and meets the specified
requirements.
Explanation: This phase is crucial for ensuring the quality and reliability of
the software. Various types of testing may be conducted, including:
o Unit testing: Testing individual modules.
o Integration testing: Testing how different modules work together.
o System testing: Testing the entire system as a whole.
o User acceptance testing (UAT): Verifying that the program meets
the end-user's needs. Errors found during testing are then debugged
(fixed) and the program is re-tested.
6. Documentation
Definition: Documentation involves creating written materials that describe
the program's functionality, design, operation, and usage.
Explanation: Comprehensive documentation is essential for future
maintenance, updates, and user understanding. It typically includes:
o User Documentation: Guides for end-users on how to operate the
software.
o System/Technical Documentation: Detailed information about the
program's design, code, and internal workings for developers and
maintainers. The guide specifically mentions:
User Manual/Reference Manual: Explains how to use the
application.
Technical Documentation: Created by programmers, often
with auto-generating tools.
Requirement Documentation: Explains what the software
does and should be able to do.
Architectural Documentation: Analyzes or communicates
software architecture, dealing with technical and non-technical
issues to guide developers and maintainers.
7. Maintenance
Definition: This ongoing phase involves activities performed after the
program has been deployed, to ensure its continued functionality,
performance, and relevance.
Explanation: Maintenance can include:
o Corrective Maintenance: Fixing bugs or defects discovered after
deployment.
o Adaptive Maintenance: Modifying the program to adapt to changes
in the environment (e.g., new operating systems, hardware).
o Perfective Maintenance: Enhancing the program's features or
performance.
o Preventive Maintenance: Making changes to prevent future
problems.
Program Structure
Program structure refers to the overall organization and logical arrangement of a
computer program's components. A well-structured program is designed for clarity,
maintainability, and efficiency. The CICT guide emphasizes structured
programming as a key approach to achieving this.
1. Structured Programming as a Foundation
Definition: Structured programming is a programming paradigm that
emphasizes the breaking down of large programs into smaller, more
manageable, and understandable units called modules or "chunks". This
approach makes extensive use of subroutines, block structures, and specific
control structures to manage program flow.
Explanation: The guide states that as programs become more complicated,
a lack of structuring makes them difficult to understand and maintain.
Structured programming addresses this by systematically reducing
complexity into manageable components. This process of breaking down
components into a sequence of smaller components is known as structured
programming.
Key Emphases of Structural Programming Approach:
o Large programs can be broken into smaller sub-programs, each
performing a single task.
o Use of a few simple control structures in solving problems.
2. Types of Program Structures/Designs
The guide identifies several types of program design, which define different ways
to structure a program:
Modularity / Modular Design
o Definition: Modularity is the process of splitting a program into
smaller, independent sections called modules or "chunks". Each
module is designed to perform a particular, single function or task.
o Explanation: This is a fundamental concept in structured
programming. Instead of writing all code in one continuous block (as
in unstructured programming), modules allow programmers to deal
with smaller, isolated parts of the system.
o Rules for Modularization:
Each module should contain one program function.
The maximum number of instructions per module should
generally not exceed 100 instructions.
Each module should have a single entry and a single exit point.
o Advantages of Modules:
Reduces effort for program changes, as changes are confined to
specific modules.
Facilitates easier testing and error removal.
Amendments to a single module do not affect the rest of the
program.
Promotes code reusability, allowing the creation of libraries for
often-used routines.
Assists in documentation by allowing descriptive naming of
modules.
Jackson's Structured Programming (JSP)
o Definition: JSP is a data structure-based method for program design,
developed by Michael Jackson. It makes use of three primary
structure diagrams (notations).
o Explanation: This method focuses on designing the program
structure based on the structure of the input and output data. The three
notations used are:
Sequence: Represents operations that are executed in a specific
order.
Iteration (Repeat): Represents a block of code that is repeated
a number of times (possibly zero) controlled by a specified
condition.
Selection: Represents a choice between different paths of
execution based on a condition.
Top-Down Design / Stepwise Refinement
o Definition: This approach involves starting with a high-level view of
the program and successively subdividing it into smaller, simpler, and
more manageable components until sufficient detail is achieved for
coding. It's also referred to as "step-down program" or "step-down
refinement".
o Explanation: An outline program is designed first, showing the main
tasks or components and their execution order. Each main component
is then reduced into smaller components, and this process continues at
each level of complexity. This method provides a methodical way to
design a program by giving a complete definition at each level.
Bottom-Up Design
o Definition: This design approach starts by solving smaller, individual
tasks or components, then integrating them to form larger tasks, and
eventually the entire program.
Monolithic Design
o Definition: This refers to the process of designing any procedure,
including analysis, coding, testing, and debugging, typically within a
single, undifferentiated block.
o Explanation: In contrast to modular or structured approaches, a
monolithic design implies a program where all code is in one place,
which the guide notes is "totally useless if working on large project".
3. Control Structures as Building Blocks of Structure
While not a "structure" in the same hierarchical sense, control structures are
fundamental to how a program's logic is structured and executed. Structured
programming heavily relies on these constructs.
Definition: Program control structures are blocks of statements that
determine how statements are to be executed.
Explanation: They dictate the flow of control within a program. The three
main control structures are:
o Sequence: Statements are executed one after another in the order they
appear.
o Selection (Decision): Execution of statements depends on a condition
that evaluates to true or false. This allows the program to make
choices. Examples include IF, IF...ELSE, NESTED IF...ELSE, and
SWITCH CASE statements.
o Iteration (Looping): This is the process of repeating the execution of
a statement until a given condition is achieved. Examples include
WHILE...LOOP, DO...WHILE LOOP, and FOR...LOOP.
4. Example of a C Program Structure
The guide provides a basic structure of a C program, illustrating how these
concepts are applied in practice:
C
#include<library-name>
main ()
{
Statement-1;
Statement-2;
.
.
.
.Statement-n
}
Explanation:
o #include<library-name>: This section includes necessary libraries
(header files) at the beginning of the program, which contain pre-
written functions.
o main (): This is the function from where program execution always
begins.
o { ... }: Curly brackets define the scope of the main() function and
encapsulate the program's statements.
o Statement-1; Statement-2; ...: These are individual instructions that
form the program's logic. Each statement typically terminates with a
semicolon
Program Writing / Implementation (Coding)
Based on the CICT Knec guide, "program writing" falls under the "Coding /
Implementation" stage of the program development cycle. This is the crucial
phase where the detailed program design is transformed into actual executable
code.
1. Coding / Implementation
Definition: This stage involves translating the program design (created
using algorithms, flowcharts, pseudocode, and structured charts) into a
specific programming language. It is the act of developing the software.
Explanation: After the problem has been thoroughly understood and a
comprehensive plan/design has been developed, the next logical step is to
write the code that will make the program functional.
o Translation of Design: Programmers use the detailed specifications
from the design phase (e.g., the logic outlined in pseudocode or
flowcharts) to write instructions in a chosen programming language
(e.g., C, C++, Java, Pascal, Visual Basic, as mentioned in the guide's
examples of high-level languages).
o Adherence to Principles: During this stage, adherence to structured
programming principles is paramount. This means:
Modularity: Breaking down the code into smaller, manageable
functions or modules, each performing a specific task. This
aligns with the principles discussed earlier, such as a single
entry and exit point for each module.
Use of Control Structures: Implementing logic using the
fundamental control structures:
Sequence: Instructions are executed one after another.
Selection (Decision): Using constructs like if-else
statements or switch-case to execute different blocks of
code based on conditions.
Iteration (Looping): Employing for, while, or do-while
loops to repeat blocks of code.
Clarity and Readability: Writing code that is easy to
understand, even by other programmers, through the use of
meaningful variable names, proper indentation, and comments.
While not explicitly detailed as part of "program writing," the
general emphasis on clarity and maintainability in structured
programming implies these practices.
o Example (from the guide's C program structure): The basic
structure of a C program given in the guide illustrates the coding
phase:
C
#include<library-name>
main ()
{
Statement-1;
Statement-2;
// ... more statements
Statement-n;
}
This snippet shows how libraries are included, the main function (a
module/entry point) is defined, and sequential statements form the
core logic.
Relationship to Previous Stages: Program writing is directly dependent on
the quality of the prior design phase. A well-designed program is
significantly easier to code, while a poorly designed one can lead to
extensive rework and bugs during the coding and testing phases.
Outcome: The primary outcome of this stage is the source code of the
program, which is then ready for compilation (if applicable) and testing. The
guide briefly mentions the creation of a "SOURCE FILE (CCP)" which then
goes through the "COMPILE" stage, implying the direct output of program
writing is a source file.
Control Structures
Definition: Program control structures are blocks of statements that determine how
statements are to be executed. They are the fundamental constructs that manage the
flow of control within a program, allowing for structured and organized code.
Explanation: In structured programming, the use of GOTO statements (which
allow unconditional jumps to any part of the code) is discouraged. Instead, control
structures provide a disciplined and logical way to control program flow,
preventing "spaghetti code" and making programs easier to read, understand, and
maintain. There are three basic types of control structures:
1. Sequence Control Structure
Definition: This is the most basic control structure where statements are
executed one after another in the exact order in which they appear in the
program.
Explanation: It represents a linear flow of instructions. Each statement is
processed completely before the next one begins. This is the default mode of
execution in most programming languages.
o Example (Conceptual):
1. Get input A.
2. Get input B.
3. Calculate Sum = A + B.
4. Display Sum.
o In the provided C program structure example:
C
main ()
{
Statement-1; // Executed first
Statement-2; // Executed second
// ...
Statement-n; // Executed last
}
The statements within the main function are executed sequentially.
2. Selection (Decision) Control Structure
Definition: This structure allows a program to make decisions and choose
which block of code to execute based on a given condition. The condition is
typically a Boolean expression that evaluates to either TRUE or FALSE.
Explanation: Selection provides branching capabilities, enabling programs
to respond differently to various inputs or situations.
o Types of Selection Structures:
IF Statement: Executes a block of code only if a condition is
true.
Conceptual Example:
IF (age >= 18) THEN
PRINT "Eligible to vote"
END IF
IF...ELSE Statement: Executes one block of code if the
condition is true, and a different block if the condition is false.
Conceptual Example:
IF (temperature > 25) THEN
PRINT "It's hot"
ELSE
PRINT "It's not hot"
END IF
Nested IF...ELSE Statements: Involves placing IF...ELSE
statements inside other IF...ELSE statements to handle multiple
conditions.
Explanation: This is used when there are more than two
possible outcomes or when a subsequent decision
depends on a prior one.
SWITCH CASE Statement (or CASE Statement): Allows
multi-way branching by checking a single variable against
multiple constant values.
Explanation: This is often used as a more readable
alternative to a long series of nested IF...ELSE IF
statements when dealing with a single variable that can
have several discrete values.
Conceptual Example:
CASE (day_of_week) OF
1: PRINT "Monday"
2: PRINT "Tuesday"
// ...
7: PRINT "Sunday"
DEFAULT: PRINT "Invalid day"
END CASE
3. Iteration (Looping) Control Structure
Definition: This structure allows a block of statements to be repeated a
specific number of times or until a certain condition is met. It is also referred
to as a repetition structure.
Explanation: Iteration is essential for tasks that require repetitive actions,
such as processing lists of data, performing calculations multiple times, or
waiting for user input.
o Types of Iteration Structures:
WHILE...LOOP (Pre-test Loop): The condition is tested
before the loop body is executed. If the condition is initially
false, the loop body will never execute.
Conceptual Example:
WHILE (count < 5) DO
PRINT count
count = count + 1
END WHILE
DO...WHILE LOOP (Post-test Loop / Repeat-Until Loop):
The loop body is executed at least once, and then the condition
is tested. If the condition is true, the loop continues.
Conceptual Example:
DO
PRINT "Enter a positive number"
READ number
WHILE (number <= 0)
FOR...LOOP (Count-Controlled Loop): Designed for
situations where the number of repetitions is known in advance.
It typically involves an initialization, a condition, and an
increment/decrement step.
Conceptual Example:
FOR (i = 1 to 10) DO
PRINT i
END FOR
These three control structures (sequence, selection, and iteration) form the
backbone of all structured programs, enabling the creation of complex logic from
simple, predictable components.
1. Definition of Sub-Programs (Modules / Functions)
Definition: Sub-programs, often referred to as modules, functions,
procedures, or subroutines, are independent sections or blocks of code
within a larger program that are designed to perform a specific, single task
or set of related tasks. They are self-contained units that can be called upon
and executed from other parts of the program.
Explanation: The guide emphasizes that "large programs can be broken into
smaller sub-programs, each performing a single task." This breakdown is the
essence of structured programming. Each sub-program acts like a miniature
program within the larger one, focusing on a particular functionality.
2. Principles Underlying Sub-Programs (Modularity) The effective use of sub-
programs is driven by the principle of Modularity:
Definition of Modularity: Modularity is the process of splitting a program
into smaller, independent sections (sub-programs/modules) where each
section is designed to perform a particular, single function.
Explanation: This principle advocates for a hierarchical structure where a
complex problem is broken down into simpler, more manageable sub-
problems, each handled by a dedicated sub-program. This systematic
approach reduces the overall complexity of the program.
3. Rules for Designing Sub-Programs (Modules) To ensure effective modularity
and robust sub-programs, the guide outlines specific rules:
Single Functionality: "Each module should contain one program function."
This means a sub-program should be designed to do one thing and do it well,
avoiding multiple unrelated tasks.
Limited Size: "The maximum number of instructions within a module
should generally not exceed 100 instructions." While this is a guideline and
not a strict rule in all modern contexts, it emphasizes keeping sub-programs
concise and manageable to maintain readability and ease of debugging.
Single Entry and Single Exit Point: "Each module should have a single
entry and a single exit point." This rule ensures a predictable and
unambiguous flow of control within and out of the sub-program, making it
easier to trace execution and avoid logical errors.
4. Advantages of Using Sub-Programs (Modules) The guide highlights several
significant benefits of adopting a sub-program structure:
Reduced Complexity: Breaking a large program into smaller, self-
contained sub-programs simplifies the overall system, making it easier to
understand and manage.
Easier Testing and Debugging: Individual sub-programs can be tested in
isolation to ensure they function correctly before integrating them into the
larger program. This simplifies the process of identifying and fixing errors.
Simplified Maintenance and Modification: If a change or amendment is
required, it can often be localized to a specific sub-program without
affecting other parts of the program. This reduces the effort and risk
associated with program modification.
Code Reusability: Well-designed sub-programs can be reused in different
parts of the same program or even in other programs. This saves
development time and effort, as commonly used functionalities do not need
to be written from scratch multiple times. It also facilitates the creation of
libraries of useful routines.
Improved Readability and Documentation: Sub-programs can be given
descriptive names that clearly indicate their purpose, which enhances
program readability and simplifies documentation.
5. Sub-Programs in Practice (Example of C Program Structure) The guide's
basic structure of a C program implicitly demonstrates the use of sub-programs,
specifically the main() function:
C
#include<library-name> // Includes other sub-programs (functions) from libraries
main () // The main sub-program where execution begins
{
Statement-1;
Statement-2;
// ... other statements, potentially calls to other sub-programs
Statement-n;
}
Program Documentation
Based on the CICT Knec guide, Program Documentation is a crucial phase in the
program development cycle. It involves creating comprehensive written materials
that describe various aspects of the program, from its design and operation to its
usage. Effective documentation is vital for the program's long-term maintainability,
future enhancements, and user understanding.
Definition: Program documentation refers to the comprehensive set of written
materials that explain the software, its design, functionality, and how it is to be
used. It serves as a record of the development process and provides guidance for
various stakeholders, including users, developers, and maintainers.
Explanation: The guide emphasizes documentation as a distinct stage after testing,
highlighting its importance for the entire lifespan of the software. It breaks down
documentation into several key types:
1. User Manual / Reference Manual
Definition: This type of documentation is designed for the end-users of the
software, providing instructions on how to operate and interact with the
program effectively.
Explanation: It typically includes information on how to install the
software, navigate its interface, perform various tasks, troubleshoot common
issues, and understand error messages. The goal is to make the software
user-friendly and accessible to individuals who may not have technical
expertise.
2. Technical Documentation
Definition: Technical documentation details the internal workings, design,
and architecture of the software. It is primarily intended for developers,
programmers, and system administrators.
Explanation: This documentation explains how the program is built, its
modules, data structures (though data structures are not detailed in this
specific guide), algorithms, and interfaces. It's crucial for understanding the
code, performing maintenance, debugging, and implementing future
modifications or enhancements. The guide notes that technical
documentation is "usually created by the programmers with the aid of Auto-
generating tools," suggesting that tools can assist in producing this type of
documentation directly from the code.
3. Requirement Documentation
Definition: Also referred to simply as "requirements documentation," this
explains what the software does and what it shall be able to do. It outlines
the functionalities, constraints, and conditions that the software must meet.
Explanation: This documentation serves as a foundational contract between
the stakeholders and the development team. It defines the scope of the
project and the expected behavior of the system. The guide points out that
the inclusion and exhaustiveness of this documentation can vary depending
on the purpose and complexity of the system. For instance:
o Applications with no safety implications or those not intended for
long-term use "may be accompanied at all."
o Conversely, applications that affect human safety or are created for
use over a long period require "exhausting documentation" of their
requirements.
4. Architectural Documentation
Definition: Also referred to as "software architecture description," this
documentation either analyzes software architectures or communicates the
results of the architectural design process.
Explanation: It focuses on the high-level structural design of the software
system. It deals with technical issues, including how different components
interact, data flow, and overall system organization. Crucially, it also covers
"non-technical issues" to provide guidance to various roles involved in the
development or use of the architecture, such as system developers,
maintenance teams, technical personnel, and even end-users. Architectural
documentation is often arranged into "architectural models," which in turn
may be organized into "different views," with each view addressing specific
concerns or aspects of the architecture.
📘 DATA STRUCTURES – CICT DETAILED NOTES (Based on KNEC Guide)
1️⃣ Definition of Data Structures
Data Structure is a specialized format for organizing, storing, and managing data
in a computer so that it can be used efficiently.
In programming, a data structure is a collection of data values, the relationships
among them, and the functions or operations that can be applied to the data.
2️⃣ Classification of Data Structures
Type Description
Primitive Data
Built-in types such as int, float, char, etc.
Structures
Non-Primitive Data Derived from primitive types. These include arrays,
Structures structures, pointers, stacks, queues, linked lists, etc.
3️⃣ Importance of Data Structures
Efficient data processing
Reduces redundancy
Enhances data organization
Enables implementation of complex algorithms
Improves problem-solving in software development
4️⃣ Types of Data Structures Covered in CICT (KNEC)
🔸 I. ARRAYS
📌 Definition:
An array is a data structure that stores a collection of elements of the same data
type using a single identifier. Each element is identified by an index or subscript.
📌 Types of Arrays:
1. One-Dimensional Array (1D)
2. Two-Dimensional Array (2D)
3. Multi-Dimensional Array (Advanced concept, briefly introduced)
✅ A. One-Dimensional Array
🧾 Syntax:
c
CopyEdit
data_type array_name[size];
🧾 Example:
c
CopyEdit
int marks[5] = {78, 90, 85, 60, 92};
🧾 Accessing Array Elements:
c
CopyEdit
printf("%d", marks[2]); // outputs 85
✅ Use Cases:
Storing exam marks
Tracking item prices
Creating lists of numbers
✅ B. Two-Dimensional Array
🧾 Definition:
A 2D array stores data in rows and columns (like a table).
🧾 Syntax:
c
CopyEdit
data_type array_name[row][column];
🧾 Example:
c
CopyEdit
int scores[2][3] = {
{70, 80, 90},
{85, 75, 95}
};
🧾 Accessing Elements:
c
CopyEdit
printf("%d", scores[1][2]); // outputs 95
✅ Use Cases:
Storing student marks in multiple subjects
Matrix operations
Timetables
🔸 II. STRUCTURES (STRUCTS)
📌 Definition:
A structure is a user-defined data type that allows the grouping of variables of
different types under one name.
Used when data items of different types are logically related (e.g., student details:
name, age, grade).
🧾 Syntax:
c
CopyEdit
struct StructureName {
data_type member1;
data_type member2;
...
};
🧾 Example:
c
CopyEdit
struct Student {
int id;
char name[30];
float marks;
};
🧾 Using Structures:
c
CopyEdit
struct Student s1;
[Link] = 101;
strcpy([Link], "Jane");
[Link] = 87.5;
✅ Use Cases:
Managing records (students, employees)
Combining multiple related values
Building databases in C
🔸 III. ARRAY OF STRUCTURES
📌 Definition:
An array of structures is a collection of structure variables stored in array form.
This is useful when dealing with multiple records.
🧾 Example:
c
CopyEdit
struct Employee {
int id;
char name[30];
float salary;
} emp[10]; // array of 10 employee records
🧾 Accessing Elements:
c
CopyEdit
emp[0].id = 1;
strcpy(emp[0].name, "Ali");
emp[0].salary = 50000;
🔸 IV. POINTERS (Briefly Covered)
📌 Definition:
A pointer is a variable that stores the memory address of another variable.
🧾 Declaration:
c
CopyEdit
int a = 10;
int *ptr = &a;
🧾 Dereferencing:
c
CopyEdit
printf("%d", *ptr); // Output: 10
✅ Use Cases:
Dynamic memory allocation
Working with arrays and structures
Efficient data handling in low-level programming
5️⃣ Comparison Table of Common Data Structures
Structure Type Stores Access Data Types Use Case
Array (1D) List of items By index Same type Marks, names
Array (2D) Table of data By row/column Same type Student marks
Grouped Employee
Structure By name Mixed types
fields records
Array of List of By index and Employee
Mixed types
Structures records field database
Depends on Dynamic
Pointer Address By reference
target memory
6️⃣ Best Practices in Data Structures
Use meaningful variable and structure names.
Always initialize arrays before use.
Ensure array indexes are within range to avoid memory errors.
Use structures for real-world entities like students, employees, etc.
Use modular design by combining data structures with functions.
🔚 CONCLUSION
Understanding data structures is essential for:
Writing efficient and organized programs.
Managing data in real-world applications.
Building the foundation for advanced programming concepts such as file
handling and databases.
Mastery of arrays, structures, and pointers is critical for passing CICT KNEC
exams and for effective problem-solving in programming.
4. Additional Concepts
Programming paradigms: The document briefly touches on different
programming paradigms, including unstructured, structured, visual, and
internet-based programming.
Software and hardware considerations: It also discusses factors to
consider when choosing software and hardware, such as cost, compatibility,
user needs, and performance