Procedural Programming C ITPP111
Total Page:16
File Type:pdf, Size:1020Kb
Procedural Programming C_ITPP111 Compiled by Tom Zimba Quality assured by Marwick Makwindi Version 1.0 NQF Level 5 Credit value: 12 January 2016 CTI EDUCATION GROUP © CTI Education Group TABLE OF CONTENTS INTRODUCTION .......................................................................................................... 5 Module aim ........................................................................................................... 5 Module description ............................................................................................... 5 Learning outcomes and assessment criteria ......................................................... 5 Summary of learning outcomes and assessment criteria ............................................... 6 Module content ..................................................................................................... 6 Lectures................................................................................................................ 8 Review questions and Let’s do it exercises ........................................................... 8 Information resources .......................................................................................... 8 Prescribed textbook ............................................................................................. 8 Recommended information sources ...................................................................... 9 Textbooks/e-Books .................................................................................................. 9 Online documents .................................................................................................... 9 Using this Study Guide ......................................................................................... 9 Purpose .............................................................................................................. 10 Structure ............................................................................................................ 10 Individual units .................................................................................................. 10 Glossary ............................................................................................................. 11 The use of icons .................................................................................................. 11 Alignment to prescribed textbook ...................................................................... 12 Study Guide/prescribed textbook alignment ............................................................... 12 Concluding remarks ............................................................................................ 13 UNIT 1 – PRINCIPLES OF PROCEDURAL PROGRAMMING .......................................... 14 Learning objectives ............................................................................................ 14 Prescribed reading ............................................................................................. 14 Introduction ....................................................................................................... 14 1.1 Characteristics of programming .............................................................. 14 1.1.1 Low-level ................................................................................................... 15 1.1.2 High-level .................................................................................................. 15 1.2 Interpreters and compilers ..................................................................... 16 1.3 Generations of programming languages ................................................. 17 1.4 Paradigms In programming .................................................................... 18 1.4.1 Procedural languages .................................................................................. 18 1.4.2 Object-oriented languages ........................................................................... 18 1.4.3 Event-driven languages ............................................................................... 19 1.5 Data Types .............................................................................................. 19 1.6 Variables................................................................................................. 19 1.7 Good Programming practice ................................................................... 20 1.7.1 Use of Comments ....................................................................................... 20 1.7.2 Indentation ................................................................................................ 20 1.7.3 Variable naming ......................................................................................... 20 1.7.4 Use of modules ........................................................................................... 20 1.8 Exercise 1 ............................................................................................... 21 Concluding remarks ............................................................................................ 21 UNIT 2 – DESIGN PROCEDURAL PROGRAMMING SOLUTIONS ................................... 22 Learning objectives ............................................................................................ 22 Prescribed reading ............................................................................................. 22 2.1 Introduction ........................................................................................... 23 2.2 Requirements specification ..................................................................... 23 2.3 Program design tools .............................................................................. 24 2.3.1 Flow Chart ................................................................................................. 24 2.3.2 Pseudo code ............................................................................................... 25 2.4 Technical Documentation ........................................................................ 25 2.5 Exercise 2 ............................................................................................... 26 Concluding remarks ............................................................................................ 26 UNIT 3 – IMPLEMENT PROCEDURAL PROGRAMMING SOLUTIONS ............................ 27 © CTI Education Group Learning objectives ............................................................................................ 27 Prescribed reading ............................................................................................. 27 Introduction ....................................................................................................... 28 3.1 Modular design ....................................................................................... 28 3.1.1 Benefits of using modules ............................................................................ 28 3.1.2 Calling a module ......................................................................................... 29 3.2 Modules in procedural programming ...................................................... 30 3.2.1 Function .................................................................................................... 30 3.2.2 Procedures ................................................................................................. 31 3.3 Exercise 3 ............................................................................................... 31 3.4 Types of variables ................................................................................... 31 3.4.1 Local ......................................................................................................... 31 3.4.2 Global ....................................................................................................... 32 3.5 Passing arguments to modules ............................................................... 33 3.5.1 Argument and parameter compatibility .......................................................... 35 3.5.2 Passing multiple arguments ......................................................................... 35 3.6 Types of passing arguments ................................................................... 36 3.6.1 Passing arguments by value ......................................................................... 36 3.6.2 Passing arguments by reference ................................................................... 36 3.7 Exercise 4 ............................................................................................... 36 3.8 Decision structures ................................................................................. 37 3.8.1 If–Then ..................................................................................................... 37 3.8.2 Boolean expressions and relational operators ................................................. 37 3.8.3 If-Then-Else ............................................................................................... 38 3.8.4 The If-Then-Else If statement....................................................................... 39 3.8.5 The case structure ...................................................................................... 40 3.9 Logical operators .................................................................................... 40 3.10 Boolean variables ..................................................................................