KCSE ONLINE

Esoma Online Revision Resources

Order this CD Today to Experience the Full Multimedia State of the Art Technology!

By the end of the lesson, you should be able to:

i.)Define programming.
ii.) Describe the various levels of programming languages.
(iii) State the advantages and disadvantages of each level of the programming language
(iv) Define the terms assembler,compiler,intrepreter,source program and object program.
(v) Describe the stages of program development.
(vi) Describe the program control structures.
(vii) Define and develop algorithm,pseudocode and flowcharts.

Background

In form two we discussed about application packages such as Word processors, Spreadsheets, Databases and Desktop publishers. These are off-shelf application software. We also have in-house developed software that are developed to suit users specific needs. All these are computer programs. These programs are developed by computer programmers using a variety of programming languages.

Lesson objectives
By the end of this lesson, you should be able to:
i.) Define the term Computer program
ii.)Define the term computer programming
iii.)Explain programming language


INTRODUCTION TO COMPUTER PROGRAMMING.

 


Background

In the previous lesson, we discussed about computer programming and highlighted programming languages, for example, during booting process a computer user will only notice different activities happening on the screen until it he/she starts using the computer. The noticeable activities on the screen are the user interface. These activities occur when a series of codes are executed by the processor. The series of instructions executed are the source code and object code respectively.

LEVELS OF PROGRAMMING LANGUAGES

 


High level languages are grouped in to four categories namely:
1. Third generation languages,
2. Fourth generation languages,
4. Object oriented programming languages and
5. web scripting languages.


Low level languages
They are the programming languages that are easily understood by the computer because they require little or no translation into object code.  These programming languages are categorized into 2 types:1st generation language  (machine language) 2nd generation language (assembly language)


Advantages and disadvantages of low level languages

Advantages

  • They are faster to execute because they  need little or no translation
  • They are stable in their execution. This is because they communicate to the hardware directly.

Disadvantages

  • They are very difficult to learn. This is because they are not close to the human language.
  • They are difficult to code/write programs. Coding requires trained experts.
  • It is difficult to debug programs created using these languages. This means it is difficult to correct errors.
  • They are machine dependant i.e. they are not portable. This means that a program written for a particular hardware type cannot be used in another type of hardware.
  • Advantages and disadvantages of high level languages

    Advantages

  • They are user friendly because they are nearer to the human language
  • They are easier to learn
  • They require less time to code
  • They are portable i.e. it is machine independent
  • They are easy to debug.
  • They are flexible hence enhancing the creativity of the programmer
    • Disadvantages

      • They require large computer memory to run in
      • Their execution consumes time. This is because the program has to be interpreted or compiled to machine readable form before the computer can execute it.

      SUMMARY OF LEVELS OF PROGRAMMING LANGUAGES

      Low level languages are Divided into:
      Machine Language and Assembly Language
      High level languages are Divided into:
      Third Generation , Fourth Generation , Object oriented Programming and Web scripting

      Background

      For a computer to run, it must be loaded with appropriate programs. These programs are developed by computer programmers who follow a series of stages to come up with the programs.In a bread manufacturing industry,bread is baked following a predefined set of stages.

      Lesson objectives
      By the end of this lesson, the learner should be able to:
      i) Describe the stages of program development.

      Program Development

      Program is developed using the following stages:

      TYPES OF ERRORS (BUGS) ENCOUNTERED DURING PROGRAM TESTING
      There are two common types of errors encountered during program testing namely; Syntax Errors and Logical Errors


      Objectives

      By the end of this lesson, the learner should be able to:
      i) State Program development tools
      ii) Develop an algorithm using a pseudo-code
      iii) Develop an algorithm using a flowchart

      Background
      In the previous lesson, we learnt about pseudo code and flow charts. The pseudo codes and flow charts provide a simplified analysis of the program logic. In this lesson we are going to discuss about program control structures.

      Lesson objectives
      By the end of this lesson, the learner should be able to:
      i) Describe the program control structures.

      Computer program

      A Computer program is a set of step by step instructions that a computer uses to perform a task.

      Computer Programming

      This is the process of writing computer programs.


      Programming Language

      This is a predefined set of symbols used to write computer instructions.


      Description of terms used in programming


      Source code

      These are the instructions written in a particular programming language.


      Object code

      This is the source code that has been converted to machine readable form.


      Translators

      A translator is a program that converts source code into object code. They are categorized as assemblers, interpreters and compilers.


      Assemblers are programs that translate programs written in assembly language into machine language.

      Interpreters are programs that translate the source program line by line allowing the CPU to execute one line before translating the next

      Compilers are programs that translate the entire source program in to object code

      Machine language

      This is first Generation Programming Language.
      Machine language instructions are written in binary code and each statement corresponds to one machine action

      Machine language

      Machine language (1st generation language) - this is a language where the instructions are written in binary code. Each statement in the binary program corresponds to one machine action.

      Assembly language

      This is second Generation Programming Language. Assembly language instructions are written symbolic instruction code

      Assembly language

      Assembly language (2nd generation language) - this is a language that is written using both shortened words (mnemonics) and binary codes. Assembly codes are translated into machine language using a program called Assembler before they are executed
      Example:
       ADD 1111, 1001 - This means that add the binary number 1111 to the binary number 1001
      SUB R1, 101 -this means subtract 101 from the contents of the register R1 and store the result in the register R1.

      PRINT R1 -this means print the contents of the register R1


       
      Graphic description of assembly language


      High level Languages

      These are programming languages that are closer to the human language. These programming languages are of 4 types:


      Third generation languages (3GLs)

      These are languages that enable a program to be divided into manageable parts called modules (procedures). They are also referred to as procedural languages.
      Examples of 3GLs are COBOL, FORTRAN, BASIC, Pascal, Ada and C.

      Fourth generation languages (4GLs)

      These are languages that have readymade tools for common programming tasks. The user builds a program by integrating these tools and their codes. These languages usually provide the user with an integrated development environment.

      Examples: SQL, NOMAD, VISUAL BASIC, Delphi Pascal and visual C++

      Object oriented programming (OOP)

      These are languages that a programming task is viewed as an object. An object is viewed as an entity that has its own set of data and functions to achieve. Several related objects grouped together make a class and several related classes make a program.  The objects interact with each other by passing messages.  

      Examples: Java, C++, Simula, small talk Web Scripting Languages

      These are languages that are used to develop dynamic web pages. They can also be used to add more functionality to a web page thereby making it more interactive.
      Examples: HTML, PHP, JAVASCRIPT, ASP.NET,ASP, VBScript, and Joomla

      PROGRAM DEVELOPMENT


      STAGES OF PROGRAM DEVELOPMENT

      Program is developed using the following stages:
      1. Problem Recognition
      2. Problem Definiton
      3. Program Design
      4. Program Coding
      5. Testing and Debugging
      6. Program Implementation



      Stage 1-Problem Recognition

      This stage tasks the program developer to understand and interpret a particular problem. The program developer sets the objectives that express the magnitude of the problem.



      Stage 1-Problem Recognition

      In this stage, a problem is identified and its magnitude expressed. It is important to be very keen in this stage as each detail affects the next stages.

      The circumstances that can cause a programmer to identify a problem:



      School Examination Processing System

      In this case study consider the problems faced by teachers when processing students' end term reports.

      Stage 2 -Problem Definition

      This stage tasks the analyst to understand and interpret a particular problem.  In this stage the analyst sets the objectives of the new program and determines the scope (boundaries) of the new program.

      School Examination Processing System

      In this stage of our case study let the students identify the necessary inputs, processes and outputs in the school examination processing system.


      School Examination Processing System

      In this stage of our case study let the students identify the necessary inputs, processes and outputs in the school examination processing system.


      STAGE 3 - PROGRAM DESIGN

      This is a stage where an analyst uses a suitable algorithm to depict a program's logic. An algorithm is a definite number of logical steps followed to solve a particular problem. Some of the tools used to design algorithms include: flowcharts, pseudo code, Entity Relation Diagrams(ERD), decision trees, data flow diagrams(DFD) and decision tables

      School Examination Processing System

      Consider the students identifying the necessary inputs, processes and outputs in the school examination processing system.


      School Examination Processing System

      In this case study consider the students developing the algorithm of school examination processing system.

      STAGE 4- PROGRAM CODING

      This is a stage where the programmer converts the program design into program source code using an appropriate programming language.


      School Examination Processing System

      In this stage the students code the examination processing system using an appropriate programming language.

      STAGE 5- PROGRAM TESTING AND DEBUGGING
      This involves going through the program so as to identify and correct errors.Program testing is running the program using test data so as to evaluate if the program generates the expected output. In case of unexpected output, the program is corrected i.e. debugged.

      School Examination Processing System

      In this stage the students go through the program so as to identify and correct errors. They create test data so to evaluate if the program generates the expected output.

      Syntax Errors:

      These are errors that occur when the programmer uses improper language rules. They are detected during dry running or when translating the program.

      Logical Errors:

      These are errors that occur when the program gives wrong results. They are not detected by translators. Example: when a programmer entered "+" instead of "x". The results would be summation instead of product.

      Solution: Go back to program code to read and identify the problem.

      Runtime errors (Computational Errors):

      These are errors that occur when the program executes properly but breaks during execution. They are detected during runtime. Some the errors include:-
      1. Rounding off errors: These are errors that occur when real numbers are adjusted to the lower or upper number.
      (e.g. 84.5 rounded to nearest whole number is 85)
      2. Truncation Errors: These are errors that occur when real numbers with long fractional parts are cut off from the fractional part
      (e.g. 84.65779 truncated to two digits is 84)

      STAGE 6 - IMPLEMENTATION


      This is a stage where the programmer delivers the program to the client and then installs it in the computers. It also involves training the client on how to use the program.  

      School Examination Processing System

      The students installs and then trains the client on how to use the programme.

      Documentation


      Program documentation involves writing support materials about the program. Some of these support materials explain how the program can be used, how the program can be installed by operators and other technical details about the program that can assist other programmers should they want to modify the program. It is very necessary to develop documentation for all stages involved in the program development
      NB: Documentation should be done at every stage


      BACKGROUND KNOWLEDGE
      In program development we learnt that the third stage is program design.  In this stage we mentioned the following two algorithm design tools; pseudo-codes and flowcharts.
      Note: An algorithm is open ended. It is therefore wise to encourage students to develop algorithms using a specific tool.


      DEFINITION AND DEVELOPMENT OF ALGORITHMS


      Pseudo-code

      Pseudo code is defined as a set of statements written in a human readable language to express the processing logic of a program.

      There are no set rules for writing the pseudo-code. When writing a pseudo-code, you must use consistent language and syntax so that it can be properly understood by the programmer and any other person.

      FLOWCHARTS


      A flowchart is a diagrammatic representation of programs processing logic.
      It uses symbols and short statements that describe various activities.


      Flowcharts

      A flowchart is a diagrammatic representation of program's processing logic.
      It uses symbols and short statements that describe various activities.


      Program flowcharts

      Program flowcharts are designed using various symbols that represent different operations.


      This flowchart shows the sequence of steps followed when opening a word processing package



      This is flowchart is for a program that prompts the user to enter two numbers ,calculates SUM, AVERAGE and GRADE. The program should output the SUM, AVERAGE and GRADE

      PROGRAM CONTROL STRUCTURES

      Program control structures are set of statements that determine how a program is excecuted.They are also defined as a set of statements in programming that allows the programmer to control the flow of the program.There are three program control structures namely; Sequence , Selection , Looping (Iteration)


      FLOWCHART FOR A PROGRAM ILLUSTRATING A SEQUENCE


      SAMPLE FLOWCHART ILLUSTRATING A SELECTION CONTROL STRUCTURE (IF..THEN..ELSE)


      Example : A teacher entering students end term marks in their reports, he/she will continue entering the marks until all entries for each student are finished.



      ELEMENTARY PROGRAMMING PRINCIPLES

       

      Sequence

      In sequence control structure the statements are executed one by one in consecutive order. It involves linear execution of statements in a program.


      Selection

      Selection control structure is used when the program is to make a decision based on a condition that is either true or false.
      For example, programmer may write a program that assigns different grades for different scores. This can be best done with selection control structure. There are three types of Selection control structures. These are;
      1. IF...THEN-This is used only when one option is available
      2. IF...THEN...ELSE-This is used when there are two available options
      3. Nested IF-This is used when two or more options have to be considered to make a selection.
      4. CASE selection-This is used as an alternative to the Nested IF and it is mainly preferred in order to reduce the many lines of codes.


      Iteration(Looping)

      This is a program control structure that allows a program to repeatedly execute a set of statements while a condition remains true. There are two categories of looping control structures namely;


      1. The -WHILE-DO LOOP-This repetitive structure tests the condition first before executing the successful code if and only if the Boolean expression returns a true value.eg to withdraw money using an ATM,a customer must have balance in his or her account.
      2. REPEAT ...UNTILL LOOP-here the code structure is executed before testing the condition. This loop stops when the Boolean statement returns a value. Eg in an ATM,a client can withdraw money until balance is equal to zero.
      3. The FOR...LOOP-This is used where the execution of the chosen statements has to be repeated a predetermined number of times.


      Order this CD Today to Experience the Full Multimedia State of the Art Technology!

      For Best results INSTALL Adobe Flash Player Version 16 to play the interactive content in your computer. Test the Sample e-Content link below to find out if you have Adobe Flash in your computer.

      Sample Coursework e-Content CD

      Other Goodies for KCSE ONLINE Members!

      Coursework e-Content CD covers all the topics for a particular class per year and costs 1200/- ( Per Subject per Class ).

      Purchase Online and have the CD sent to your nearest Parcel Service. Pay the amount to Patrick 0721806317 by M-PESA then provide your address for delivery of the Parcel. Alternatively, you can use BUY GOODS TILL NUMBER 827208 Ask for clarification if you get stuck.

      Install ADOBE Flash Player for Best Results

      For Best results INSTALL Adobe Flash Player Version 16 to play the interactive content in your computer. Test the link below to find out if you have Adobe Flash in your computer.

      Search

      Subject Menu