Information Communication Technology  ·  Level 6
Computer Programming Principles
Chapter 2: Demonstrate Structured programming skills
📚 10 Topics
⚑ What you will be able to do

By the end of this chapter, you will be able to:

  • Declare identifiers correctly following program design specifications.
  • Compile computer programs accurately according to system requirements.
  • Initialize variables and constants properly as specified in the program design.
  • Apply user-defined data types correctly when required by the system.
  • Create program input accurately based on design needs.
  • Use data control structures correctly according to design requirements.
  • Implement data structures following the program design specifications.
  • Develop program subroutines that effectively meet user needs.
  • Code program output correctly to satisfy user requirements.
  • Perform debugging safely and effectively following work procedures.

Mastering these skills will help you build reliable, efficient programs that work exactly as intended in real-world computer programming tasks.

Programming in C language remains a fundamental skill for ICT Technicians in Kenya, particularly when developing structured and maintainable software solutions. Mastery of declaring identifiers, initializing variables, and managing constants is crucial for writing clear, efficient, and error-free programs. This chapter focuses on demonstrating structured programming skills by exploring core concepts in C, enabling technicians to align code with design specifications and industry best practices. These skills underpin professional software development in diverse Kenyan workplaces such as county government offices, banks, and educational institutions.

2.1 Declaration of Identifiers in C Language

The declaration of identifiers is the foundation of any C program, providing meaningful names for variables, constants, functions, and arrays. In Kenya’s ICT sector, where software must meet precise requirements and be easily maintained, proper declaration enhances code readability and debugging efficiency. This topic covers naming conventions, best practices, and ensuring identifiers conform to program design, which is essential for collaboration and code quality.

2.1.1 Guidelines for Naming Conventions and Best Practices

Naming conventions in C programming guide developers to create identifiers that are meaningful, consistent, and compliant with language rules. Good naming reduces ambiguity and facilitates code maintenance, which is vital in environments like Kenyan universities and banks where multiple programmers may work on the same project.

Guidelines for Naming Conventions

  • Descriptive Names: Identifiers should clearly describe their purpose or the data they hold, for example, studentAge instead of sa, enhancing code understandability.
  • Use of Lowercase and Underscores: Employ lowercase letters with underscores to separate words, such as total_sales, which is a common practice in C to improve readability.
  • Avoid Reserved Keywords: Names must not clash with C reserved keywords like int, return, or while, as this causes compilation errors.
  • Consistency Across the Codebase: Maintain uniform naming style throughout the program to ensure consistency, which is particularly important in team projects at institutions like the Kenya Revenue Authority (KRA).
  • Meaningful Abbreviations: When abbreviations are necessary, use standard or well-understood ones, for example, qty for quantity, to avoid confusion.

Best Practices for Naming Identifiers

In addition to following naming conventions, adhering to best practices ensures identifiers contribute to program quality and maintainability in Kenyan ICT environments:

  • Keep Names Short but Descriptive: While names should be meaningful, avoid overly long identifiers that make code cumbersome. For example, use empSalary instead of employeeSalaryForJune2024, especially in payroll systems at Nairobi County offices.
  • Use Consistent Case Styles: Decide on a case style (such as snake_case or camelCase) and apply it consistently throughout the codebase. This is important in collaborative projects at the Kenya Revenue Authority, where uniformity aids team understanding.
  • Prefix Global Identifiers: For variables or functions with global scope, prefix names with a module or project identifier, such as payroll_ for payroll-related functions, to prevent naming conflicts in large systems like those at Equity Bank.
  • Avoid Ambiguous Abbreviations: Only use abbreviations that are widely understood. For example, use amt for amount, but avoid non-standard abbreviations like tp for total price, which may confuse new developers in a university IT department.
  • Document Identifier Purpose: Add comments explaining the role of complex or critical identifiers, especially when they represent business rules or regulatory requirements, such as NHIFDeduction in county hospital payroll systems.

Best Practices for Naming Identifiers

In addition to following naming conventions, adhering to best practices ensures identifiers contribute to program quality and maintainability in Kenyan ICT environments:

  • Keep Names Short but Descriptive: While names should be meaningful, avoid overly long identifiers that make code cumbersome. For example, use empSalary instead of employeeSalaryForJune2024, especially in payroll systems at Nairobi County offices.
  • Use Consistent Case Styles: Decide on a case style (such as snake_case or camelCase) and apply it consistently throughout the codebase. This is important in collaborative projects at the Kenya Revenue Authority, where uniformity aids team understanding.
  • Prefix Global Identifiers: For variables or functions with global scope, prefix names with a module or project identifier, such as payroll_ for payroll-related functions, to prevent naming conflicts in large systems like those at Equity Bank.
  • Avoid Ambiguous Abbreviations: Only use abbreviations that are widely understood. For example, use amt for amount, but avoid non-standard abbreviations like tp for total price, which may confuse new developers in a university IT department.
  • Document Identifier Purpose: Add comments explaining the role of complex or critical identifiers, especially when they represent business rules or regulatory requirements, such as NHIFDeduction in county hospital payroll systems.

2.1.2 Ensuring Identifiers Align with Program Design Specifications

Aligning identifiers with program design specifications ensures that the code reflects the logical structure and functionality outlined during the design phase. This practice supports traceability and eases future modifications, which is critical in systems deployed in hospitals or SACCOs where accuracy and clarity are paramount.

Techniques to Align Identifiers with Design

  • Mapping Identifiers to Design Elements: Use names that correspond directly to entities and attributes defined in design documents, such as patientID for a hospital management system.
  • Reflecting Data Types in Names: Incorporate hints about data types in identifiers when appropriate, for example, prefixing boolean variables with is or has like isActive.
  • Modular Naming: For functions and variables related to specific modules, include the module name as a prefix, such as auth_login for authentication login functions.
  • Avoiding Ambiguity: Ensure that identifiers are unique and not misleading, preventing errors during implementation in complex projects like county government payroll systems.
  • Review and Refactor: Regularly review code against design documents and refactor identifiers to maintain alignment, especially during iterative development cycles.
The rest of this chapter
🔒

Create a free account to open more of this chapter.

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒2.2 Initializing Variables and Constants in C Language

Proper initialization of variables and constants is a critical step that affects program correctness and performance. Kenyan ICT technicians must understand different initialization techniques to prevent undefined behavior and ensure that programs operate reli…

🔒2.3 Applying User-Defined Data Types in C language

In ICT work, mastering user-defined data types in C is essential for developing scalable and maintainable software solutions. User-defined data types enable programmers to model real-world entities and complex data beyond the primitive types provided by the la…

🔒2.4 Creating Computer program input in C language

Accepting and processing input is a fundamental aspect of interactive C programs. For ICT technicians working on systems such as retail point-of-sale applications or hospital appointment scheduling, correctly handling user input ensures reliable and user-frien…

🔒2.5 Application of Data Control Structures in C Program

In Kenya's ICT sector, especially among technicians working in software development and system maintenance, understanding how to apply control structures in C programming is vital for creating efficient and reliable applications. Control structures guide the f…

🔒2.6 Data Structures in C Program

Data structures organise and store data efficiently to facilitate access and modification. This is essential for ICT technicians developing software systems that handle large volumes of data, such as retail inventory systems or customer databases. Choosing the…

🔒2.7 Creating C Computer Program Subroutines

In the role of an ICT Technician in Kenya, writing efficient and maintainable code is essential for supporting business operations, whether in a county government office managing data systems or a retail business automating sales processes. Subroutines in C pr…

🔒2.8 Coding of C Computer Program Output

In the Kenyan ICT sector, especially among technicians working in software development and system support, effectively coding program output in C is essential for delivering precise, user-friendly applications. Output coding determines how data is displayed or…

🔒2.9 Performing C Computer Program Debugging

Debugging is a critical skill for ICT technicians in Kenya, ensuring software reliability and performance in environments ranging from university labs to county government offices. Effective debugging practices help identify and fix errors that could otherwise…

🔒2.10 Compiling C Computer Program

Compiling a C program is a critical step for ICT Technicians in Kenya who develop software solutions for diverse sectors such as banking, healthcare, and government services. Compilation transforms human-readable source code into machine-readable instructions…

Chapter Summary

This chapter covered essential structured programming skills in the C language, starting with the declaration of identifiers, emphasizing the importance of following naming conventions and aligning identifiers with program design specifications. It then explored the initialization of variables and constants, highlighting techniques that ensure proper setup according to design needs. User-defined data types, including structures, classes, arrays, and functions, were examined alongside criteria for selecting appropriate types based on system requirements. The creation of program input and the application of data control structures such as selection, loops, and sequence were discussed with a focus on best practices for implementation. Common data structures like arrays, queues, stacks, and linked lists were introduced, with guidance on choosing suitable structures for specific designs. The chapter also addressed the creation of subroutines, explaining their benefits and how to design them to meet user needs. Finally, it covered coding program output, performing systematic debugging using various techniques and tools, and the compilation process, ensuring programs comply with system requirements throughout.

Self-Assessment

🔒 PDFDownload this self-assessment, with answers

A. Written Assessment

  1. What are the key rules for declaring identifiers in the C programming language? (3 marks)
  2. Explain why proper initialization of variables and constants is critical in C programming. (3 marks)
🔒20 more in this section.

Chapter Examination Questions

🔒 PDFDownload these examination questions, with worked answers

SECTION A (40 Marks) - Answer ALL Questions

  1. Explain the importance of following naming conventions when declaring identifiers in a C program used at a Kenyan county government finance office. (4 marks)
  2. Describe how improper initialization of variables can affect program execution in a banking application such as Equity Bank. (4 marks)
🔒18 more in this section.

Chapter Practical Activities

Practical 1: Declare and name identifiers in C program segment

Information Communication Technology · Level 6
Computer Programming Principles
PRACTICAL ASSESSMENT
TIME: 4 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Write a C program segment declaring five variables and two constants with appropriate data types and naming conventions as per the given specifications.
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Computer installed with C compiler and IDEFoolscap paper
Pen
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Computer installed with C compiler and IDE1 Pc per Candidate
2Foolscap paper5 Sheets per Candidate
3Pen1 Pc per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Setup Development Environment
Identified and selected C programming language in the IDE
(Award 1 mark or 0)
1
Opened the correct C compiler or IDE
(Award 2 marks or 0)
2
Sub-Total3
TASK 2: Declare Identifiers Correctly
Declared five variables with appropriate C data types as specified
(Award 1 mark for each correctly declared variable or 0)
5
Declared two constants with correct data types and const keyword
(Award 1 mark for each correctly declared constant or 0)
2
Used correct and meaningful identifier names following C naming conventions
(Award 3 marks or 0)
3
Sub-Total10
TASK 3: Compile and Execute Program Segment
Successfully compiled the program segment without errors
(Award 1 mark or 0)
1
Executed the program segment (if applicable) or ensured syntax correctness
(Award 1 mark or 0)
1
Debugged and corrected any syntax errors found
(Award 2 marks or 0)
2
Code is neatly formatted and properly commented explaining identifiers
(Award 3 marks or 0)
3
Sub-Total7
PRODUCT CHECKLIST
Program segment correctly declares all identifiers with proper data types and naming conventions
(Award 5 marks or 0)
5
Program compiles and runs without errors
(Award 5 marks or 0)
5
Sub-Total10
GRAND TOTAL30
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)

Practical 2: Initialize Variables and Constants in C Program

Information Communication Technology · Level 6
Computer Programming Principles
PRACTICAL ASSESSMENT
TIME: 4 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Write a C program that initializes at least six variables of different data types and three constants, including integer, float, char, and string, and displays their values on the console.
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Computer installed with C compiler and IDEFoolscap paper
Pen
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Computer installed with C compiler and IDE1 Pc per Candidate
2Foolscap paper5 sheets per Candidate
3Pen1 Pc per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Setup Development Environment
Identified and selected the C programming language
(Award 1 mark or zero)
1
Opened the correct IDE or compiler for C programming
(Award 2 marks or zero)
2
Sub-Total3
TASK 2: Develop the Program
Declared six variables using appropriate data types (int, float, char, string)
(Award 1 mark for each correctly declared variable or zero)
6
Declared three constants correctly using #define or const keyword
(Award 1 mark for each correctly declared constant or zero)
3
Initialized all variables and constants with valid values as per design requirements
(Award 4 marks or zero)
4
Used meaningful and valid identifiers for variables and constants
(Award 2 marks or zero)
2
Sub-Total15
TASK 3: Compile and Execute Program
Successfully compiled the program without errors
(Award 1 mark or zero)
1
Executed the program and displayed initialized values on console
(Award 1 mark or zero)
1
Tested program using sample data and debugged any errors
(Award 3 marks or zero)
3
Code is neatly formatted and properly commented
(Award 2 marks or zero)
2
Sub-Total7
PRODUCT CHECKLIST
Program correctly initializes six variables and three constants with appropriate data types and values
(Award 6 marks or zero)
6
Program output displays all initialized variables and constants clearly and correctly
(Award 4 marks or zero)
4
Sub-Total10
GRAND TOTAL35
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)
🔒

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒Implement User-Defined Data Types in C to Manage Student RecordsPractical 3
🔒Develop a C Program to Manage Student Scores Using ArraysPractical 4
🔒Design and implement modular C functions for calculating employee payrollPractical 5
🔒Select Appropriate C Data Types for Employee Payroll VariablesPractical 6
🔒Develop a C program to accept and process employee salary inputPractical 7
🔒Develop a C program using selection, loops, and sequence control structuresPractical 8
🔒Develop a C program to manage student marks using arraysPractical 9
🔒Implement Queue Data Structure with Enqueue and Dequeue Operations in CPractical 10
🔒Implement a Stack Data Structure in C with Push and Pop OperationsPractical 11
🔒Implement a Singly Linked List in C with Basic OperationsPractical 12
🔒Select and Implement Appropriate Data Structures in CPractical 13
🔒Debug a C program calculating employee net salaryPractical 14
🔒Compile and verify a C program for system compliancePractical 15
Flashcards 20 cards Study deck ▾
Question
1

↻ Tap card to reveal answer
🔒

18 more in this section.

Create a free account
Test Yourself 15 questions Start quiz ▾
0%
0 / 2
🔒

13 more in this section.

Create a free account
Am I competent?

At the start of this chapter we promised you would be able to:

  • Declare identifiers correctly following program design specifications.
  • Compile computer programs accurately according to system requirements.
  • Initialize variables and constants properly as specified in the program design.
  • Apply user-defined data types correctly when required by the system.
  • Create program input accurately based on design needs.
  • Use data control structures correctly according to design requirements.
  • Implement data structures following the program design specifications.
  • Develop program subroutines that effectively meet user needs.
  • Code program output correctly to satisfy user requirements.
  • Perform debugging safely and effectively following work procedures.

Tick each one you can genuinely do.

So, are you there yet?

You're competent when you can confidently do 50% or more of what this chapter promised.

Sign in to record how you're doing.