SlideShare une entreprise Scribd logo
1  sur  38
CHAPTER 5
                    PROGRAMMING
    1.0 BASIC PROGRAMMING CONCEPTS

1.1 Definition of program and programming language
 A computer program is a series of step by step
instructions telling the computer what to do.
 A programming language is a set of words (reserved
words such as Dim, If, Then, For, Next) symbols (=,*,&) and
codes (set of rules) that enables humans to communicate
with computers.
 Programming languages are used to write computer
program or develop software.
Examples of programming languages are COBOL, Java,
Javascript, HTML, Visual Basic 6.0, Ada, C, C++, C#, Pascal,
Ruby, Perl, BASIC,Prolog and Smalltalk.
1.2 Levels and generation of programming laguages

LOW LEVEL PROGRAMMING LANGUAGES

Low-level programming languages designed for a particular
complete and reflecting its internal machine code; low-
level languages are therefore often described as machine-
oriented languages that closer to the hardware.
Low-level programming language
 Generation                  Explanation                   Examples
First           Machine language is a set of
Generation      instructions and data that a
                computer’s central processing unit
                can execute directly.                      Machine
                                                           Language
                Machine languages instructions use a
                series of binary digits (1s and 0s) or a
                combination of numbers and letters
                that represent binary digits.
Low-level programming language
 Generation                  Explanation                  Examples
Second        Assembly language is the human-readable
Generation    notation for the machine language used
              to control specific computer operations.
                                                          Assembly
              An assembly language programmer writes      Language
              instructions using symbolic instruction
              codes that are meaningful abbreviations
              or mnemonics.

              With this language, a programmer write
              abbreviations such as ADD for addition,
              CMP for compare, MUL for multiply.

              An assembler is a program that translates
              assembly language into machine
              language.
1.2 Levels and generation of programming laguages

HIGH LEVEL PROGRAMMING LANGUAGES

High-level programming languages allow the specification
of a problem solution in terms closer to those used by
human beings. These languages were designed to make
programming far easier, less error-prone and to remove the
programmer from having to know the details of the
internal structure of a particular computer. These high-level
languages were much closer to human language.
High-level programming language
 Generation                 Explanation                  Examples
Third         The third generation of programming
Generation    language 3GL or procedural language uses
              a series of English-like words that are
              closer to human language to write           BASIC
              instructions.                               LOGO
                                                         SmallTalk
              High-level programming languages make
              complex programming simpler and easier         C
              to read, write and maintain.                 C++
                                                          Pascal
              Program written in a high level              Java
              programming language must be translated
              into machine language by a compiler or
              interpreter.
High-level programming language

 Generation                  Explanation                   Examples
Fourth        The fourth generation programming
Generation    language or non-procedural language,
              often abbreviated as 4GL, enables users to
              access data in a database. SQL can be          SQL
              used to query data.                          NOMAD
                                                            FOCUS
              A very high-level programming language is    Intellect
              usually limited to a very specific
              application that might use syntax which is
              never used in other programming
              languages.
High-level programming language

 Generation                 Explanation                   Examples
Fifth         The fifth generation programming
Generation    language or visual programming language
              is also known as natural language.
                                                          Prolog
              Provides a visual or graphical interface,   Mercury
              called a visual programming environment,
              for creating source codes.

              Fifth generation programming language
              allows people to interact with without
              needing any specialize knowledge.
1.3 PROGRAMMING LANGUAGE APPROACHES
       PROGRAMMING LANGUAGE APPROACHES


  Object-Oriented Approach         Structured Approach

(a) Object-Oriented approach is a computer programming
    techniques based on the concept of an “object” that
    combine both data and the function into a single unit.
    Programming approaches may includes features such as
    encapsulation, polymorphism and inheritance.
    Examples of OOP : C++, Java, Visual Basic 2005, C#
(a) Structured approach is computer programming
    technique in which the program is divided into modules
    like function, subroutine and procedure.
    Examples: Pascal, C
DIFFERENCES BETWEEN OOP AND STRUCTURED APPROACH
      STRUCTURED        Differences         OBJECT-ORIENTED
       APPROACH                                 APPROACH
Structured                 Uses        Object-Oriented approach
programming                            uses object
approached uses a top
down design model
The programmer          Emphasize      The programmer packages
divides programming                    the data and the function
problem into module                    into a single unit, an object
like function
Medium programming      Suitable for   Large programming language
language
1.4 TRANSLATION METHOD OF PROGRAMMING USING
       ASSEMBLER, INTERPRETER & COMPILER




               TRANSLATOR


  Assembler       Interpreter     Compiler
(a) An Assembler is a computer program that translates
    assembly language into machine language.
(b) An Interpreter is a computer program that translates a
    high-level language into machine language. Interpreter
    translates programming statement of a program into
    machine language; no object code is saved and then
    executes it immediately, line by line. (Interpreted code
    generally run more slowly)
(c) A Compiler is a computer program that translates a
    high-level language into machine language. Compiler
    translates entire programming statement of a program
    into machine language, save it in an object code file
    and then executes it later.
DIFFERENCES BETWEEN INTERPRETER AND COMPILER
     INTERPRETER          Differences             COMPILER
Translate programming                   Translate entire
statement line by line      Method      programming statement and
and execute it                          execute it later.
immediately
No object code is saved   Object code   Store machine language as
                                        object code on the disk
Interpreted code run      Running time Compiled code run faster
slower
(a) An Assembler is a computer program that translates
    assembly language into machine language.
(b) An Interpreter is a computer program that translates a
    high-level language into machine language. Interpreter
    translates programming statement of a program into
    machine language; no object code is saved and then
    executes it immediately, line by line. (Interpreted code
    generally run more slowly)
(c) A Compiler is a computer program that translates a
    high-level language into machine language. Compiler
    translates entire programming statement of a program
    into machine language, save it in an object code file
    and then executes it later.
Study Case: Microsoft Visual Basic

Visual Basic programming language uses both an
interpreter and a compiler. The programmer can use the
interpreter during program development. When the
program is complete and error free, the programmer can
compile the program so it runs faster when it is placed into
production for users to execute.
1.5 BASIC ELEMENTS IN PROGRAMMING
                        (A) CONSTANT
                         (B) VARIABLE
      CONSTANT           differences           VARIABLES
Constant retain their   Characteristics Variables can change
value during program                    their value during
execution                               program execution
const PI = 3.142          examples      Dim Name as String
Const GRAVITY = 9.8                     Dim Score as Integer
Const WAGE = 5.5                        Dim Mark as Integer
1.6 DATA TYPES
            (a) Boolean (b) Integer (c) Double
                     (d) String (e) Date
 Data type determines the type of data a variable can store,
              for example a number or a character.
  DATA TYPES                     EXPLANATION
Integer        Integer data type contains any whole number
(Number)       value that does not have any frictional part
               Examples: Age, Mark and Temperature.
               17, 85 and -5
Double         Double data type contains any decimal number
(Number)       value that has a fractional part.
               Examples: Wages, Fees and Weight
               RM 3500.45, RM 33.00, 33.3 kg
DATA TYPES                        EXPLANATION
String            String data type contains a sequence of
(Text)            character.
                  Examples: Name, Address and IC Number.
                  Ahmad, Jalan 2 Taman Permata, 850306-02-
                  5264
Boolean           Boolean data type contains either a true or
(Logical Value)   false value.
                  Examples: Paid (school fee), Result, Passed and
                  Married (Marital Status)
                  If Not Paid then msgbox(“Please pay
                  immediately)
                  If Passed then msgbox(“Good”)
Date              Date data type contains date and time value.
                  Examples: DOB, Date of payment, Time
                  7/8/91, 2-Sept-2007, 12:24 AM
1.7 MATHEMATICAL AND LOGICAL OPERATORS

Operator is a symbol or notation that tells a computer to
            perform certain actions or operation.

MATHEMATICAL    MEANING
 OPERATOR                     LOGICAL       MEANING
                             OPERATOR
     +             Plus
                                And        And Operator
     -            Minus
                                 Or         Or Operator
     *           Multiply
                                Not        Not Operator
      /           Divide
Comparison Operator or Relational Operator

COMPARISON              MEANING
 OPERATOR
     >                Greater Than
     <                 Less Than
     =                   Equal
    <>                     Not
    <=              Less Than or Equal
DIFFERENCES BETWEEN MATHEMATICAL
                AND LOGICAL OPERATOR


     Mathematical         Differences             Logical
Mathematical                            Logical operators are
operators are notations                 notations that tell the
that tell the computer                  computer to perform
to perform                 Function     logical operations such
mathematical                            check the status of two
operations such as                      Boolean values
addition, subtraction,
multiplication and
division
       +, -, *, /          Symbol             And, Or, Not
1.8    SEQUENCE CONTROL STRUCTURE AND SELECTION
               CONTROL STRUCTURE
     SEQUENCE CONTROL                SELECTION CONTROL
          STRUCTURE                       STRUCTURE
A sequence control structure   A selection control structure will
executes statement one by      execute statements based on
one in linear order            certain conditions
Programmer uses sequence       Programmer uses selection
control structure when         control structure when he/she
he/she want to execute code    want to implement decision
line by line                   making process in the program
The program does not use       The program has to use the
the decision symbol            decision symbol
SEQUENCE CONTROL                  SELECTION CONTROL
      STRUCTURE                          STRUCTURE


                             False
         Action 1                         Condition


         Action 2
                                                True
         Action 3            Action 2      Action 1

Sequence Control Structure     Selection Control Structure
SEQUENCE CONTROL                 SELECTION CONTROL
       STRUCTURE                         STRUCTURE
Example 1:                    Example 1:
  Dim marks as integer          If marks > 50 then
  Input “Please enter marks”;        Print “Passed”
  mark                           else
Example 2:                           Print “Failed”
  Dim no1 as integer             End If
  Dim no2 as integer          Example 2:
  no = 4                         If answer = no1 + no2 Then
  no = 6                               Print “Excellent”
  Print “Addition”               Else
  Print “Number 1”; no1                Print “Please, Try Again”
  Print “Number 2”; no2          End if
  Input “Your answer”;
  answer
1.9 FLOW CHART

SYMBOLS      NAMES              EXPLANATION
            Terminal      Use to show the
           Begin or End   beginning or end of a
                          program
             Flowline     Use to connect symbols
                          and indicate the
                          sequences of operation
          Input or output Use to show either an
           (Print/Display) input operation(e.g an
                           input from the user) or an
                           output operation (e.g
                           print or display messages)
1.9 FLOW CHART

SYMBOLS     NAMES                EXPLANATION
            Process        Use to show a process to
           (Formula)       be carried out (e.g.
                           calculation)
             Decision      Use to shows a decision
          (If-Then-Else)   (or choice) to be made.
                           The program should
                           continue along one of two
                           routes (e.g. if…then…else)
1.9 FLOW CHART
Draw a flow chart to show how a program calculates the
area of a circle.          Begin


                        Get length,
                        base, width



                    Volume of a cuboid =
                     length*base*width


                      Print volume
                       of a cuboid



                            End
Draw a flow chart to make a decision. If student has more
than 50 marks then he will pass.       Begin



                                        Get mark




                       False
                                      Mark > 50


                                                   True

               Print “Failed”         Print “Pass”




                                End
1.10 PSEUDO CODES
•Pseudo codes is text only sentences that describe the logic
and program flow of a computer program.
•Pseudo code assembles plain English.
•It usually does not have any specific programming language
syntax and grammar.
•Pseudo code is directly linked to the computer codes
because each pseudo code statement can often be
converted into the programming language virtually line by
line.
•There are no set of rules for writing pseudo code.
•A programmer can have his or her personalized pseudo
code.
•He or she must use consistent language and syntax in the
pseudo code, so that he or she can understand it at a later
stage.
Write a pseudo code to show how a program calculates the
area of a circle.

Pseudo Code
         Begin
           Get radius
           Calculate area of a circle = ½ * PI * radius 2
           Print area of circle
         End
Draw a flow chart to make a decision. If student has more
than 50 marks then he will pass.


Pseudo Code
         Begin
           Get marks
           If mark > 50 Then
                 Print “Passed”
           Else
                 Print “Failed”
           End If
         End
2.0 PROGRAMME DEVELOPMENT PHASES


5 MAIN PHASES IN PROGRAM DEVELOPMENT

           • Problem Analysis

            •Program Design

                •Coding

          •Testing & Debugging

            •Documentation
PROBLEM ANALYSIS


1. Identify input, processing, output and data
   component
2. Refer to book and website
3. Ask expert
4. Meet with system analyst and users
PROGRAM DESIGN

1. Divide all program activities into program
   modules
2. Create solution algorithm for each program
   modules (logic structure)
3. Describe the flow or steps of a program with
   English statement. (pseudo code)
4. Create a pictorial diagram of the logical
   sequence of a program (flowchart)
5. Design/Draw user interface
CODING


1. Coding a program involves translating the
   solution algorithm into programming
   language usually on paper.
2. Typing the code into the computer using
   programming language such as Pascal, C++
   and Visual Basic.
TESTING AND DEBUGGING

Several methods have been devised for finding
and removing logic error and syntax error.
1. Manually testing with sample data
2. The program is run through a computer,
   using a translator program. Before the
   program will run, it must be free of syntax
   errors. Such errors will be identified by the
   translator.
3. Testing by a select group of potential users.
   Potential users try out the program and
   provide feedback.
DOCUMENTATION

Documentation is important for people who may involve
with the program in the future.

Programmers: As time passes, even the creator of the
original program may not remember much about it. Other
programmers wishing to update and modify it (program
maintenance)
DOCUMENTATION

Activity:
1. Produce a description of the program, layouts of the
   input and output records and a program listing.
2. Produce a problem definition, flow chart and pseudo
   code.
3. Write comments with the program code(internal
   documentation). These comments explain the
   program’s purpose of the code statements within the
   program.
4. Write a document for a novice users that explains how
   to use or operate the program (write a user guide).

Contenu connexe

Tendances (20)

C language ppt
C language pptC language ppt
C language ppt
 
History of c
History of cHistory of c
History of c
 
Learn C
Learn CLearn C
Learn C
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
C basics
C   basicsC   basics
C basics
 
C tokens
C tokensC tokens
C tokens
 
Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming Languages
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Lecture 1- History of C Programming
Lecture 1- History of C Programming Lecture 1- History of C Programming
Lecture 1- History of C Programming
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
C++
C++C++
C++
 
Graphical programming
Graphical programmingGraphical programming
Graphical programming
 

En vedette

En vedette (20)

Bab 2 struktur sel dan fungsi
Bab 2  struktur sel dan fungsiBab 2  struktur sel dan fungsi
Bab 2 struktur sel dan fungsi
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Flowchart for volume and surface area of cylinder
Flowchart for volume and surface area of cylinderFlowchart for volume and surface area of cylinder
Flowchart for volume and surface area of cylinder
 
Manual pengguna membuat sites
Manual pengguna membuat sitesManual pengguna membuat sites
Manual pengguna membuat sites
 
Inheritance
InheritanceInheritance
Inheritance
 
Nutrisi
NutrisiNutrisi
Nutrisi
 
Reproduction and Growth
Reproduction and GrowthReproduction and Growth
Reproduction and Growth
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Bab 3 pergerakan bahan2 merentasi membran plasma
Bab 3 pergerakan bahan2 merentasi membran plasmaBab 3 pergerakan bahan2 merentasi membran plasma
Bab 3 pergerakan bahan2 merentasi membran plasma
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Lesson 2.2
Lesson 2.2Lesson 2.2
Lesson 2.2
 
Lesson 3.1 part 2
Lesson 3.1 part 2Lesson 3.1 part 2
Lesson 3.1 part 2
 
Lesson 1.5
Lesson 1.5Lesson 1.5
Lesson 1.5
 
Lesson 3.1 part 2
Lesson 3.1 part 2Lesson 3.1 part 2
Lesson 3.1 part 2
 
Lesson 2.3
Lesson 2.3Lesson 2.3
Lesson 2.3
 
Lesson 1.6
Lesson 1.6Lesson 1.6
Lesson 1.6
 

Similaire à Chapter 5

La5 ict-topic-5-programming
La5 ict-topic-5-programmingLa5 ict-topic-5-programming
La5 ict-topic-5-programmingKak Yong
 
Trend of Visual Programming Language
Trend of Visual Programming LanguageTrend of Visual Programming Language
Trend of Visual Programming LanguageTeddy Marcus
 
Chapter 5-programming
Chapter 5-programmingChapter 5-programming
Chapter 5-programmingAten Kecik
 
La5 ict-topic-5-programming
La5 ict-topic-5-programmingLa5 ict-topic-5-programming
La5 ict-topic-5-programmingAzmiah Mahmud
 
Introduction Programming and Application Lecture 1.pptx
Introduction Programming and Application Lecture 1.pptxIntroduction Programming and Application Lecture 1.pptx
Introduction Programming and Application Lecture 1.pptxMahamaHaruna
 
Form5 cd1
Form5 cd1Form5 cd1
Form5 cd1smktsj2
 
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docAmanGunner
 
2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdfKINGZzofYouTube
 
Computer languages and generation
Computer languages and generationComputer languages and generation
Computer languages and generationMunawar Bukhari
 
Development of computer languages
Development of computer languagesDevelopment of computer languages
Development of computer languagesluckas chauhan
 
Introduction To Computer Programming
Introduction To Computer ProgrammingIntroduction To Computer Programming
Introduction To Computer ProgrammingHussain Buksh
 
English de lenguaje de programacion
English de lenguaje de programacionEnglish de lenguaje de programacion
English de lenguaje de programacionVillalba Griselda
 

Similaire à Chapter 5 (20)

Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Notacd07
Notacd07Notacd07
Notacd07
 
Nota programming
Nota programmingNota programming
Nota programming
 
Programming Part 01
Programming Part 01Programming Part 01
Programming Part 01
 
Notacd071
Notacd071Notacd071
Notacd071
 
La5 ict-topic-5-programming
La5 ict-topic-5-programmingLa5 ict-topic-5-programming
La5 ict-topic-5-programming
 
Ict topic 5
Ict topic 5Ict topic 5
Ict topic 5
 
Trend of Visual Programming Language
Trend of Visual Programming LanguageTrend of Visual Programming Language
Trend of Visual Programming Language
 
Chapter 5-programming
Chapter 5-programmingChapter 5-programming
Chapter 5-programming
 
La5 ict-topic-5-programming
La5 ict-topic-5-programmingLa5 ict-topic-5-programming
La5 ict-topic-5-programming
 
La5 programming
La5  programmingLa5  programming
La5 programming
 
Introduction Programming and Application Lecture 1.pptx
Introduction Programming and Application Lecture 1.pptxIntroduction Programming and Application Lecture 1.pptx
Introduction Programming and Application Lecture 1.pptx
 
Computer languages 11
Computer languages 11Computer languages 11
Computer languages 11
 
Form5 cd1
Form5 cd1Form5 cd1
Form5 cd1
 
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
 
2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdf
 
Computer languages and generation
Computer languages and generationComputer languages and generation
Computer languages and generation
 
Development of computer languages
Development of computer languagesDevelopment of computer languages
Development of computer languages
 
Introduction To Computer Programming
Introduction To Computer ProgrammingIntroduction To Computer Programming
Introduction To Computer Programming
 
English de lenguaje de programacion
English de lenguaje de programacionEnglish de lenguaje de programacion
English de lenguaje de programacion
 

Dernier

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Chapter 5

  • 1. CHAPTER 5 PROGRAMMING 1.0 BASIC PROGRAMMING CONCEPTS 1.1 Definition of program and programming language  A computer program is a series of step by step instructions telling the computer what to do.  A programming language is a set of words (reserved words such as Dim, If, Then, For, Next) symbols (=,*,&) and codes (set of rules) that enables humans to communicate with computers.  Programming languages are used to write computer program or develop software. Examples of programming languages are COBOL, Java, Javascript, HTML, Visual Basic 6.0, Ada, C, C++, C#, Pascal, Ruby, Perl, BASIC,Prolog and Smalltalk.
  • 2. 1.2 Levels and generation of programming laguages LOW LEVEL PROGRAMMING LANGUAGES Low-level programming languages designed for a particular complete and reflecting its internal machine code; low- level languages are therefore often described as machine- oriented languages that closer to the hardware.
  • 3. Low-level programming language Generation Explanation Examples First Machine language is a set of Generation instructions and data that a computer’s central processing unit can execute directly. Machine Language Machine languages instructions use a series of binary digits (1s and 0s) or a combination of numbers and letters that represent binary digits.
  • 4. Low-level programming language Generation Explanation Examples Second Assembly language is the human-readable Generation notation for the machine language used to control specific computer operations. Assembly An assembly language programmer writes Language instructions using symbolic instruction codes that are meaningful abbreviations or mnemonics. With this language, a programmer write abbreviations such as ADD for addition, CMP for compare, MUL for multiply. An assembler is a program that translates assembly language into machine language.
  • 5. 1.2 Levels and generation of programming laguages HIGH LEVEL PROGRAMMING LANGUAGES High-level programming languages allow the specification of a problem solution in terms closer to those used by human beings. These languages were designed to make programming far easier, less error-prone and to remove the programmer from having to know the details of the internal structure of a particular computer. These high-level languages were much closer to human language.
  • 6. High-level programming language Generation Explanation Examples Third The third generation of programming Generation language 3GL or procedural language uses a series of English-like words that are closer to human language to write BASIC instructions. LOGO SmallTalk High-level programming languages make complex programming simpler and easier C to read, write and maintain. C++ Pascal Program written in a high level Java programming language must be translated into machine language by a compiler or interpreter.
  • 7. High-level programming language Generation Explanation Examples Fourth The fourth generation programming Generation language or non-procedural language, often abbreviated as 4GL, enables users to access data in a database. SQL can be SQL used to query data. NOMAD FOCUS A very high-level programming language is Intellect usually limited to a very specific application that might use syntax which is never used in other programming languages.
  • 8. High-level programming language Generation Explanation Examples Fifth The fifth generation programming Generation language or visual programming language is also known as natural language. Prolog Provides a visual or graphical interface, Mercury called a visual programming environment, for creating source codes. Fifth generation programming language allows people to interact with without needing any specialize knowledge.
  • 9. 1.3 PROGRAMMING LANGUAGE APPROACHES PROGRAMMING LANGUAGE APPROACHES Object-Oriented Approach Structured Approach (a) Object-Oriented approach is a computer programming techniques based on the concept of an “object” that combine both data and the function into a single unit. Programming approaches may includes features such as encapsulation, polymorphism and inheritance. Examples of OOP : C++, Java, Visual Basic 2005, C# (a) Structured approach is computer programming technique in which the program is divided into modules like function, subroutine and procedure. Examples: Pascal, C
  • 10. DIFFERENCES BETWEEN OOP AND STRUCTURED APPROACH STRUCTURED Differences OBJECT-ORIENTED APPROACH APPROACH Structured Uses Object-Oriented approach programming uses object approached uses a top down design model The programmer Emphasize The programmer packages divides programming the data and the function problem into module into a single unit, an object like function Medium programming Suitable for Large programming language language
  • 11. 1.4 TRANSLATION METHOD OF PROGRAMMING USING ASSEMBLER, INTERPRETER & COMPILER TRANSLATOR Assembler Interpreter Compiler
  • 12. (a) An Assembler is a computer program that translates assembly language into machine language. (b) An Interpreter is a computer program that translates a high-level language into machine language. Interpreter translates programming statement of a program into machine language; no object code is saved and then executes it immediately, line by line. (Interpreted code generally run more slowly) (c) A Compiler is a computer program that translates a high-level language into machine language. Compiler translates entire programming statement of a program into machine language, save it in an object code file and then executes it later.
  • 13. DIFFERENCES BETWEEN INTERPRETER AND COMPILER INTERPRETER Differences COMPILER Translate programming Translate entire statement line by line Method programming statement and and execute it execute it later. immediately No object code is saved Object code Store machine language as object code on the disk Interpreted code run Running time Compiled code run faster slower
  • 14. (a) An Assembler is a computer program that translates assembly language into machine language. (b) An Interpreter is a computer program that translates a high-level language into machine language. Interpreter translates programming statement of a program into machine language; no object code is saved and then executes it immediately, line by line. (Interpreted code generally run more slowly) (c) A Compiler is a computer program that translates a high-level language into machine language. Compiler translates entire programming statement of a program into machine language, save it in an object code file and then executes it later.
  • 15. Study Case: Microsoft Visual Basic Visual Basic programming language uses both an interpreter and a compiler. The programmer can use the interpreter during program development. When the program is complete and error free, the programmer can compile the program so it runs faster when it is placed into production for users to execute.
  • 16. 1.5 BASIC ELEMENTS IN PROGRAMMING (A) CONSTANT (B) VARIABLE CONSTANT differences VARIABLES Constant retain their Characteristics Variables can change value during program their value during execution program execution const PI = 3.142 examples Dim Name as String Const GRAVITY = 9.8 Dim Score as Integer Const WAGE = 5.5 Dim Mark as Integer
  • 17. 1.6 DATA TYPES (a) Boolean (b) Integer (c) Double (d) String (e) Date Data type determines the type of data a variable can store, for example a number or a character. DATA TYPES EXPLANATION Integer Integer data type contains any whole number (Number) value that does not have any frictional part Examples: Age, Mark and Temperature. 17, 85 and -5 Double Double data type contains any decimal number (Number) value that has a fractional part. Examples: Wages, Fees and Weight RM 3500.45, RM 33.00, 33.3 kg
  • 18. DATA TYPES EXPLANATION String String data type contains a sequence of (Text) character. Examples: Name, Address and IC Number. Ahmad, Jalan 2 Taman Permata, 850306-02- 5264 Boolean Boolean data type contains either a true or (Logical Value) false value. Examples: Paid (school fee), Result, Passed and Married (Marital Status) If Not Paid then msgbox(“Please pay immediately) If Passed then msgbox(“Good”) Date Date data type contains date and time value. Examples: DOB, Date of payment, Time 7/8/91, 2-Sept-2007, 12:24 AM
  • 19. 1.7 MATHEMATICAL AND LOGICAL OPERATORS Operator is a symbol or notation that tells a computer to perform certain actions or operation. MATHEMATICAL MEANING OPERATOR LOGICAL MEANING OPERATOR + Plus And And Operator - Minus Or Or Operator * Multiply Not Not Operator / Divide
  • 20. Comparison Operator or Relational Operator COMPARISON MEANING OPERATOR > Greater Than < Less Than = Equal <> Not <= Less Than or Equal
  • 21. DIFFERENCES BETWEEN MATHEMATICAL AND LOGICAL OPERATOR Mathematical Differences Logical Mathematical Logical operators are operators are notations notations that tell the that tell the computer computer to perform to perform Function logical operations such mathematical check the status of two operations such as Boolean values addition, subtraction, multiplication and division +, -, *, / Symbol And, Or, Not
  • 22. 1.8 SEQUENCE CONTROL STRUCTURE AND SELECTION CONTROL STRUCTURE SEQUENCE CONTROL SELECTION CONTROL STRUCTURE STRUCTURE A sequence control structure A selection control structure will executes statement one by execute statements based on one in linear order certain conditions Programmer uses sequence Programmer uses selection control structure when control structure when he/she he/she want to execute code want to implement decision line by line making process in the program The program does not use The program has to use the the decision symbol decision symbol
  • 23. SEQUENCE CONTROL SELECTION CONTROL STRUCTURE STRUCTURE False Action 1 Condition Action 2 True Action 3 Action 2 Action 1 Sequence Control Structure Selection Control Structure
  • 24. SEQUENCE CONTROL SELECTION CONTROL STRUCTURE STRUCTURE Example 1: Example 1: Dim marks as integer If marks > 50 then Input “Please enter marks”; Print “Passed” mark else Example 2: Print “Failed” Dim no1 as integer End If Dim no2 as integer Example 2: no = 4 If answer = no1 + no2 Then no = 6 Print “Excellent” Print “Addition” Else Print “Number 1”; no1 Print “Please, Try Again” Print “Number 2”; no2 End if Input “Your answer”; answer
  • 25. 1.9 FLOW CHART SYMBOLS NAMES EXPLANATION Terminal Use to show the Begin or End beginning or end of a program Flowline Use to connect symbols and indicate the sequences of operation Input or output Use to show either an (Print/Display) input operation(e.g an input from the user) or an output operation (e.g print or display messages)
  • 26. 1.9 FLOW CHART SYMBOLS NAMES EXPLANATION Process Use to show a process to (Formula) be carried out (e.g. calculation) Decision Use to shows a decision (If-Then-Else) (or choice) to be made. The program should continue along one of two routes (e.g. if…then…else)
  • 27. 1.9 FLOW CHART Draw a flow chart to show how a program calculates the area of a circle. Begin Get length, base, width Volume of a cuboid = length*base*width Print volume of a cuboid End
  • 28. Draw a flow chart to make a decision. If student has more than 50 marks then he will pass. Begin Get mark False Mark > 50 True Print “Failed” Print “Pass” End
  • 29. 1.10 PSEUDO CODES •Pseudo codes is text only sentences that describe the logic and program flow of a computer program. •Pseudo code assembles plain English. •It usually does not have any specific programming language syntax and grammar. •Pseudo code is directly linked to the computer codes because each pseudo code statement can often be converted into the programming language virtually line by line. •There are no set of rules for writing pseudo code. •A programmer can have his or her personalized pseudo code. •He or she must use consistent language and syntax in the pseudo code, so that he or she can understand it at a later stage.
  • 30. Write a pseudo code to show how a program calculates the area of a circle. Pseudo Code Begin Get radius Calculate area of a circle = ½ * PI * radius 2 Print area of circle End
  • 31. Draw a flow chart to make a decision. If student has more than 50 marks then he will pass. Pseudo Code Begin Get marks If mark > 50 Then Print “Passed” Else Print “Failed” End If End
  • 32. 2.0 PROGRAMME DEVELOPMENT PHASES 5 MAIN PHASES IN PROGRAM DEVELOPMENT • Problem Analysis •Program Design •Coding •Testing & Debugging •Documentation
  • 33. PROBLEM ANALYSIS 1. Identify input, processing, output and data component 2. Refer to book and website 3. Ask expert 4. Meet with system analyst and users
  • 34. PROGRAM DESIGN 1. Divide all program activities into program modules 2. Create solution algorithm for each program modules (logic structure) 3. Describe the flow or steps of a program with English statement. (pseudo code) 4. Create a pictorial diagram of the logical sequence of a program (flowchart) 5. Design/Draw user interface
  • 35. CODING 1. Coding a program involves translating the solution algorithm into programming language usually on paper. 2. Typing the code into the computer using programming language such as Pascal, C++ and Visual Basic.
  • 36. TESTING AND DEBUGGING Several methods have been devised for finding and removing logic error and syntax error. 1. Manually testing with sample data 2. The program is run through a computer, using a translator program. Before the program will run, it must be free of syntax errors. Such errors will be identified by the translator. 3. Testing by a select group of potential users. Potential users try out the program and provide feedback.
  • 37. DOCUMENTATION Documentation is important for people who may involve with the program in the future. Programmers: As time passes, even the creator of the original program may not remember much about it. Other programmers wishing to update and modify it (program maintenance)
  • 38. DOCUMENTATION Activity: 1. Produce a description of the program, layouts of the input and output records and a program listing. 2. Produce a problem definition, flow chart and pseudo code. 3. Write comments with the program code(internal documentation). These comments explain the program’s purpose of the code statements within the program. 4. Write a document for a novice users that explains how to use or operate the program (write a user guide).