SlideShare une entreprise Scribd logo
1  sur  14
F1001 PROGRAMMING FUNDAMENTALS




  UNIT

    2

PROBLEM SOLVING

 Programming Life Cycle
 Program Design




                                               17
F1001 PROGRAMMING FUNDAMENTALS


PROGRAMMING LIFE CYCLE

•   Life Cycle: Refers to the changes made from an old to a new program (the cycle starts again).

•   Programming Life Cycle: A framework or discipline, which uses certain techniques needed in
    computer programming development.
•   Steps involved in programming life cycle:




        PROBLEM ANALYSIS




                PROGRAM DESIGN




                                PROGRAM CODING




                                          TESTING AND DEBUGGING




                                                                   MAINTENANCE




                                                                              DOCUMENTATION



STEP 1: PROBLEM ANALYSIS
Purpose:
•   To describe in detail a solution to a problem and information needed in solving the problem.


    How?
•   Study and understand the problem.
•   Identify:
    o    The needed input.
    o    The required output.
    o    The needed process. For example: scientific formula or particular theories.


                                                                                                    18
F1001 PROGRAMMING FUNDAMENTALS


    Problem 1: Write a program that will get 3 numbers as input from the users. Find the average and
                  display the three numbers and its average.


                  Problem Analysis:
                           Input: 3 numbers.
                           Process: 1. Add the three numbers
                                      2. Divide the total of the three numbers with 3
                           Output:             The three numbers and its average




                   INPUT                              PROCESS                           OUTPUT




STEP 2: PROGRAM DESIGN

•   Definition: It is a framework or flow that shows the steps in problem solving.

•   Methods to design a program:
    1.   Algorithm
            Algorithm is a sequence of instructions to solve a problem, written in human language, and it
             can solve any problems when it is used with the correct procedure.
            A programmer writes the problem solving in the form of an algorithm before coding it into
             computer language.
            Example of algorithm to calculate the average of three numbers:
             1.   Set Total=0, Average=0;
             2.   Input 3 numbers
             3.   Total up the 3 numbers
                      Total= total of 3 numbers
             4.   Calculate average
                      Average=Total/3
             5.   Display 3 numbers and the average




                                                                                                       19
F1001 PROGRAMMING FUNDAMENTALS


  2.     Flowchart
         •   A graphical representation of data, information and workflow using certain symbols that are
             connected to flow lines to describe the instructions done in problem solving.
         •   It shows the flow of the process from the start to the end of the problem solving.

                  Carta alir / Flowchart                      Penerangan / Explanation




                         START
                                                    •   Enter data from keyboard
                                                    •   Calculate total
                         Input
                                                    •   Display data and total



                        Process



                        Output



                         END




  •      Explanation of basic flowchart symbol:
Simbol / Symbol               Penerangan / Explanation                     Algorithma / Algorithm



                                                                                                       20

       Decision
F1001 PROGRAMMING FUNDAMENTALS



                     Indicate the direction of data flow.
                     Used to connect a block to another
                      block.
Flow Lines


                     Indicates operations / process             Variable = instruction
                      involved.

   Process



                     Receive / read value                       Input (list out variable names)
                     Display value                              Output (result)
Input / Output

                                                                 <execute instruction that does not
                     Execute decision based on
                                                                 fulfil the condition>
                      condition.
                     Test is performed and the program
                      flow continues, based on the result.




                     Indicates the beginning and end of         START
                            START
                      a flowchart.                               END
   Start / End
  Flow Lines

                            Input
                     Show the continuing flowchart in
                      the same page.
  On-page
  connector                                  True
                          Condition                          True Statement



                     False


                        False statement



                                                                 Outpu
                                                                 t


                                                                                                      21

                                                                 END
F1001 PROGRAMMING FUNDAMENTALS




            Symbol Usage
  Symbol                            Explanation

                          Flowchart continues in the next
                           page.

Off Page
Connector




               START

                                             B

               Input
                                          Outpu
                                          t


             Process
                                            END



               B                          Next page


             First page



                           Symbol Usage
                                                               22
F1001 PROGRAMMING FUNDAMENTALS




•   There are few additional symbols of flowchart used in a complicated program: GOSUB and
    RETURN. It’s usually used in a big program.


              Symbol                             Explanation

                                    Instruct the executed instruction to
                                     move to the next function
             GOSUB



                                    Instruct the executed instruction to
                                     return to the next instruction after
                                     the GOSUB instruction, called the
             RETURN
                                     function.




                       START                                   area




                        Input                     area =22 / 7 * radius * radius
                        radius


                       GOSUB                               Output
                        area                                 area




                       END                                 RETURN




                                        Symbol Usage




                                                                                       23
F1001 PROGRAMMING FUNDAMENTALS


          •   Example Flowchart:
              Flowchart to calculate the total of fine for late returning of library books.


                                             START



                                                Input
                                            total_of_day



                                   Fine = total_of_day * 0.20



                                           Output Fine

                                                                                Symbol Usage
     3.       Pseudocode
          •   Steps in problem solving that is END half in programming code and half in human
                                               written
              language.
          •   For example, some part uses C language code and some part uses Malay or English language.
          •   Advantages:
                 Easily understood.
                 Easily maintained.
                 The codes are changeable.
          •   Disadvantages:
                 Cannot be executed in the computer.
          •   Example:

                            START
                                     Total=0, Average=0
                                     Input a, b, c
                                     Total = a + b + c
                                     Average = Total / 3
                                     Output a, b, c
                                     Output Average
                            END


4.   Structure Charts
     •    Structure chart is an additional method in preparing programs that has many sub modules.




                                                                                                     24
F1001 PROGRAMMING FUNDAMENTALS


  •    It consists rectangular boxes, which represents all the sub modules in a program and is connected
       by arrows.
  •    It illustrates the top-down design of a program and is also known as hierarchical chart because its
       components are in hierarchical form.
  •    The advantage is that it is easy to be drawn and to be changed.
  •    Format:

                                              MainModule




           SubModule 1                        SubModule 2                      SubModule 3




  •    Example 1: SubModule 2.1
                                                                       SubModule 2.2
        Problem: To calculate the amount of water bill

                                              Water bill




  Display                                                  Determine
                     Get / read         Compute                               Display         Print
instructions                                                the late
                       data            the charge                             the bill       the bill
  for user                                                  charge



                                  Represent the modules in the program




  •    Example 2:
           Problem: To calculate area of a circle


           Structure Charts:               Area of a circle




        Display                                                                          Print
      instructions       Get / read         Compute             Define       Display
                                                                                          the
        for user           data             the area           the area      the area
                                                                                         area

                                                                                                        25
                                    Represent the modules in the program
F1001 PROGRAMMING FUNDAMENTALS




STEPS 3: PROGRAM CODING

•   Definition: Writing problem solving into certain programming language such as C, COBOL and
    others.

•   Problem solving: Instructions before it is coded into programming language.

•   Purpose: To produce a program to develop a system.

                                                         # include <stdio.h>
                                                         main( )
                                                         {
                                                         int a, b, c, Total;
        Example of syntax in C                           double Average;
        language to display                              Total=0, Average=0
        instruction for user to                          printf(" Enter 3 numbers:");
        enter 3 numbers on                               scanf("%d %d %d",&a, &b, &c);
        computer screen.                                 Total = a + b + c;
                                                         Average = Total / 3;
                                                         printf("a = %d b = %d c = %d ", a, b, c);
                                                         printf("Average is = %f", Average);
                                                         return 0;
                                                         }




                                                                                                     26
F1001 PROGRAMMING FUNDAMENTALS


STEP 4: TESTING AND DEBUGGING
•     Definition of Testing:
            Using a set of data to discover errors and to ensure accuracy of the program.
•     Testing Process:
            Diagram indicates the process of testing:


    Input sample of                                                             Output (functioning well or
                                           Executing Program
                                                                                     error discovered)
           data set

•     Example 1:
      Assume that a program to find the average of 3 numbers has been coded. Then, execute the program.
      Using a few numbers, test the program to verify whether the result is as expected.
      Testing 1:
                 Input: 4,5,8
      Testing 2:                         From the output, has the program produced the expected result?
                 Input: 7,8,6
            An error is known as bug.
            Debugging is a process of identifying and correcting error.


•     Two types of error:
      1.     Syntax Error (grammatical error)
                Occurs when the rules of programming language are not applied.
                Correction is done during the program coding.
                The bug can be traced during the compilation.
                Also known as compile-time error
                Must be corrected before executing and testing the program.

      2.     Logic error
                Cannot be traced by compiler.
                                                                                Syntax error will occur if
                Corrected during the problem solving process.
                                                                                there is any mistake in the
                Also known as run time error.
                                                                                program.
                Example output for average is 4, but when it runs, the output is 2.
                                                                                Example:
                                                                                     No semicolon at the end
                                                                                     of the instruction.




                                                 Syntax error message
    Line 9 where syntax error                                                                                  27
    occurred.
                                                    SYNTAX ERROR
F1001 PROGRAMMING FUNDAMENTALS




                                                  -   Logic error is an error that occurs
# include <stdio.h>
                                                      because logical statement in program
main( )
                                                      is wrong
{
                                                  -   Example:
int a, b, c, Total;
                                                      Sum is total of the 3 numbers.
double Average;
                                                      Supposedly the average is sum / 3
Total=0, Average=0
                                                      because there are 3 numbers.
printf(" Enter 3 numbers:");
scanf("%d %d %d",&a, &b, &c);
Total = a + b + c;
Average = Total / 6;
printf("a = %d b = %d c = %d ", a, b, c);
 printf("Average is = %f", Average);
 return 0;                         Logic Error
}


 The wrong               Input three numbers:
                         444                             LOGIC ERROR
 output
                         Average of the
                         numbers: 2




                                                                                             28
F1001 PROGRAMMING FUNDAMENTALS




STEP 5: MAINTENANCE
Definition:
•   Activity that verifies whether the operational system is performing as planned or an activity to modify
    the system to meet the current requirement.
•   The process of changing a system after it has been applied to maintain its ability. The changes may
    involve simple changes such as error correcting.


    How to do maintenance?
•   By performing activities such as:
    o    Testing – Test the ability of the system.
    o    Measurement – Access data time. Example, time to save, print and others.
    o    Replacement – Replace the old system to new system.
    o    Adjustment – Adding needs to new system.
    o    Repair – For example: An old system cannot update the new data
    o    Updating – Update the database.


•   Example: Maintenance of Telecommunication System TELEKOM.
    o         Telecommunication System TELEKOM provides communication service from one house to
              another house. The telephone number is 7 digits.
    o         Assume that management will change the number of digit from 7 digits to 8 digits.
    o         Programmer will change the old system to a new system and test the system whether it is
              functioning well or not.
    o         Then, the new systems overall capability will be tested. For example, the capability to
              identify the caller’s and the user’s location and time taken to connect them (measurement)
              will be tested.
    o         Any old function that is no longer used will be replaced with a new function (replacement).



STEP 6: DOCUMENTATION
Definition: A written or graphical report of the steps taken during the development of a program.


Purpose: It will be useful in the future, in case of modification or maintenance.


    Content of Documentation:




                                                                                                           29
F1001 PROGRAMMING FUNDAMENTALS


o   Description of the program.
o   Specification of program requirement
o   Program design such as pseudocode and flowchart
o   List of program and comments (to explain about the program).
o   Test results.
o   User’s manual book.
o   Program capabilities and limitation.




                                                                       30

Contenu connexe

Tendances

Problem solving (C++ Programming)
Problem solving (C++ Programming)Problem solving (C++ Programming)
Problem solving (C++ Programming)Umair Younas
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowcharthermiraguilar
 
As Level Computer Science Book -2
As Level Computer Science  Book -2As Level Computer Science  Book -2
As Level Computer Science Book -2DIGDARSHAN KUNWAR
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1YOGESH SINGH
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer scienceumardanjumamaiwada
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAKTabsheer Hasan
 

Tendances (14)

Algorithms
AlgorithmsAlgorithms
Algorithms
 
Raptor tool
Raptor toolRaptor tool
Raptor tool
 
Unit 3
Unit 3Unit 3
Unit 3
 
Problem solving (C++ Programming)
Problem solving (C++ Programming)Problem solving (C++ Programming)
Problem solving (C++ Programming)
 
Computer Programming - Lecture 2
Computer Programming - Lecture 2Computer Programming - Lecture 2
Computer Programming - Lecture 2
 
Subprogramms
SubprogrammsSubprogramms
Subprogramms
 
Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowchart
 
As Level Computer Science Book -2
As Level Computer Science  Book -2As Level Computer Science  Book -2
As Level Computer Science Book -2
 
Introduction to Flowchart
Introduction to FlowchartIntroduction to Flowchart
Introduction to Flowchart
 
intro to c
intro to cintro to c
intro to c
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAK
 

En vedette (16)

Unit 3
Unit 3Unit 3
Unit 3
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
 
Fp201 unit1 1
Fp201 unit1 1Fp201 unit1 1
Fp201 unit1 1
 
Kandungan nota
Kandungan notaKandungan nota
Kandungan nota
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 13 - Progra...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 13 - Progra...Understanding Computers: Today and Tomorrow, 13th Edition Chapter 13 - Progra...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 13 - Progra...
 
Software Development Techniques
Software Development TechniquesSoftware Development Techniques
Software Development Techniques
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 

Similaire à Unit 2

Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithmDHANIK VIKRANT
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdfprakashvs7
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartPrasanna R Kovath
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C LanguageAryan Ajmer
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfSusieMaestre1
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptLecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptcosc242101003
 
algorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfalgorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfAmanPratik11
 
Pseudo code.pptx
Pseudo code.pptxPseudo code.pptx
Pseudo code.pptxChaya64047
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.pptfaithola1
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answersmkengkilili2011
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c languagekamalbeydoun
 

Similaire à Unit 2 (20)

Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdf
 
Chap6
Chap6Chap6
Chap6
 
CHAPTER 1
CHAPTER 1CHAPTER 1
CHAPTER 1
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chart
 
Comp102 lec 1
Comp102   lec 1Comp102   lec 1
Comp102 lec 1
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
lecture 5
 lecture 5 lecture 5
lecture 5
 
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptLecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Flow charts
Flow chartsFlow charts
Flow charts
 
algorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfalgorithms and flow chart overview.pdf
algorithms and flow chart overview.pdf
 
Flowcharts
FlowchartsFlowcharts
Flowcharts
 
Pseudo code.pptx
Pseudo code.pptxPseudo code.pptx
Pseudo code.pptx
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.ppt
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answer
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
 

Plus de rohassanie

Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012rohassanie
 
FP 202 - Chapter 5
FP 202 - Chapter 5FP 202 - Chapter 5
FP 202 - Chapter 5rohassanie
 
Chapter 3 part 2
Chapter 3 part 2Chapter 3 part 2
Chapter 3 part 2rohassanie
 
Chapter 3 part 1
Chapter 3 part 1Chapter 3 part 1
Chapter 3 part 1rohassanie
 
FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3rohassanie
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2) rohassanie
 
Labsheet 7 FP 201
Labsheet 7 FP 201Labsheet 7 FP 201
Labsheet 7 FP 201rohassanie
 
Labsheet 6 - FP 201
Labsheet 6 - FP 201Labsheet 6 - FP 201
Labsheet 6 - FP 201rohassanie
 
Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012rohassanie
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1rohassanie
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 studrohassanie
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 studrohassanie
 
Chapter 1 part 3
Chapter 1 part 3Chapter 1 part 3
Chapter 1 part 3rohassanie
 
Chapter 1 part 2
Chapter 1 part 2Chapter 1 part 2
Chapter 1 part 2rohassanie
 
Chapter 1 part 1
Chapter 1 part 1Chapter 1 part 1
Chapter 1 part 1rohassanie
 

Plus de rohassanie (19)

Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012
 
FP 202 - Chapter 5
FP 202 - Chapter 5FP 202 - Chapter 5
FP 202 - Chapter 5
 
Chapter 3 part 2
Chapter 3 part 2Chapter 3 part 2
Chapter 3 part 2
 
Chapter 3 part 1
Chapter 3 part 1Chapter 3 part 1
Chapter 3 part 1
 
FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3
 
Lab ex 1
Lab ex 1Lab ex 1
Lab ex 1
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
Labsheet 7 FP 201
Labsheet 7 FP 201Labsheet 7 FP 201
Labsheet 7 FP 201
 
Labsheet 6 - FP 201
Labsheet 6 - FP 201Labsheet 6 - FP 201
Labsheet 6 - FP 201
 
Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012
 
Labsheet 5
Labsheet 5Labsheet 5
Labsheet 5
 
Labsheet 4
Labsheet 4Labsheet 4
Labsheet 4
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 stud
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 stud
 
Chapter 1 part 3
Chapter 1 part 3Chapter 1 part 3
Chapter 1 part 3
 
Chapter 1 part 2
Chapter 1 part 2Chapter 1 part 2
Chapter 1 part 2
 
Chapter 1 part 1
Chapter 1 part 1Chapter 1 part 1
Chapter 1 part 1
 

Dernier

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 

Dernier (20)

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 

Unit 2

  • 1. F1001 PROGRAMMING FUNDAMENTALS UNIT 2 PROBLEM SOLVING  Programming Life Cycle  Program Design 17
  • 2. F1001 PROGRAMMING FUNDAMENTALS PROGRAMMING LIFE CYCLE • Life Cycle: Refers to the changes made from an old to a new program (the cycle starts again). • Programming Life Cycle: A framework or discipline, which uses certain techniques needed in computer programming development. • Steps involved in programming life cycle: PROBLEM ANALYSIS PROGRAM DESIGN PROGRAM CODING TESTING AND DEBUGGING MAINTENANCE DOCUMENTATION STEP 1: PROBLEM ANALYSIS Purpose: • To describe in detail a solution to a problem and information needed in solving the problem. How? • Study and understand the problem. • Identify: o The needed input. o The required output. o The needed process. For example: scientific formula or particular theories. 18
  • 3. F1001 PROGRAMMING FUNDAMENTALS Problem 1: Write a program that will get 3 numbers as input from the users. Find the average and display the three numbers and its average. Problem Analysis: Input: 3 numbers. Process: 1. Add the three numbers 2. Divide the total of the three numbers with 3 Output: The three numbers and its average INPUT PROCESS OUTPUT STEP 2: PROGRAM DESIGN • Definition: It is a framework or flow that shows the steps in problem solving. • Methods to design a program: 1. Algorithm  Algorithm is a sequence of instructions to solve a problem, written in human language, and it can solve any problems when it is used with the correct procedure.  A programmer writes the problem solving in the form of an algorithm before coding it into computer language.  Example of algorithm to calculate the average of three numbers: 1. Set Total=0, Average=0; 2. Input 3 numbers 3. Total up the 3 numbers Total= total of 3 numbers 4. Calculate average Average=Total/3 5. Display 3 numbers and the average 19
  • 4. F1001 PROGRAMMING FUNDAMENTALS 2. Flowchart • A graphical representation of data, information and workflow using certain symbols that are connected to flow lines to describe the instructions done in problem solving. • It shows the flow of the process from the start to the end of the problem solving. Carta alir / Flowchart Penerangan / Explanation START • Enter data from keyboard • Calculate total Input • Display data and total Process Output END • Explanation of basic flowchart symbol: Simbol / Symbol Penerangan / Explanation Algorithma / Algorithm 20 Decision
  • 5. F1001 PROGRAMMING FUNDAMENTALS  Indicate the direction of data flow.  Used to connect a block to another block. Flow Lines  Indicates operations / process  Variable = instruction involved. Process  Receive / read value  Input (list out variable names)  Display value  Output (result) Input / Output <execute instruction that does not  Execute decision based on fulfil the condition> condition.  Test is performed and the program flow continues, based on the result.  Indicates the beginning and end of  START START a flowchart.  END Start / End Flow Lines Input  Show the continuing flowchart in the same page. On-page connector True Condition True Statement False False statement Outpu t 21 END
  • 6. F1001 PROGRAMMING FUNDAMENTALS Symbol Usage Symbol Explanation  Flowchart continues in the next page. Off Page Connector START B Input Outpu t Process END B Next page First page Symbol Usage 22
  • 7. F1001 PROGRAMMING FUNDAMENTALS • There are few additional symbols of flowchart used in a complicated program: GOSUB and RETURN. It’s usually used in a big program. Symbol Explanation  Instruct the executed instruction to move to the next function GOSUB  Instruct the executed instruction to return to the next instruction after the GOSUB instruction, called the RETURN function. START area Input area =22 / 7 * radius * radius radius GOSUB Output area area END RETURN Symbol Usage 23
  • 8. F1001 PROGRAMMING FUNDAMENTALS • Example Flowchart: Flowchart to calculate the total of fine for late returning of library books. START Input total_of_day Fine = total_of_day * 0.20 Output Fine Symbol Usage 3. Pseudocode • Steps in problem solving that is END half in programming code and half in human written language. • For example, some part uses C language code and some part uses Malay or English language. • Advantages:  Easily understood.  Easily maintained.  The codes are changeable. • Disadvantages:  Cannot be executed in the computer. • Example: START Total=0, Average=0 Input a, b, c Total = a + b + c Average = Total / 3 Output a, b, c Output Average END 4. Structure Charts • Structure chart is an additional method in preparing programs that has many sub modules. 24
  • 9. F1001 PROGRAMMING FUNDAMENTALS • It consists rectangular boxes, which represents all the sub modules in a program and is connected by arrows. • It illustrates the top-down design of a program and is also known as hierarchical chart because its components are in hierarchical form. • The advantage is that it is easy to be drawn and to be changed. • Format: MainModule SubModule 1 SubModule 2 SubModule 3 • Example 1: SubModule 2.1 SubModule 2.2  Problem: To calculate the amount of water bill Water bill Display Determine Get / read Compute Display Print instructions the late data the charge the bill the bill for user charge Represent the modules in the program • Example 2:  Problem: To calculate area of a circle  Structure Charts: Area of a circle Display Print instructions Get / read Compute Define Display the for user data the area the area the area area 25 Represent the modules in the program
  • 10. F1001 PROGRAMMING FUNDAMENTALS STEPS 3: PROGRAM CODING • Definition: Writing problem solving into certain programming language such as C, COBOL and others. • Problem solving: Instructions before it is coded into programming language. • Purpose: To produce a program to develop a system. # include <stdio.h> main( ) { int a, b, c, Total; Example of syntax in C double Average; language to display Total=0, Average=0 instruction for user to printf(" Enter 3 numbers:"); enter 3 numbers on scanf("%d %d %d",&a, &b, &c); computer screen. Total = a + b + c; Average = Total / 3; printf("a = %d b = %d c = %d ", a, b, c); printf("Average is = %f", Average); return 0; } 26
  • 11. F1001 PROGRAMMING FUNDAMENTALS STEP 4: TESTING AND DEBUGGING • Definition of Testing:  Using a set of data to discover errors and to ensure accuracy of the program. • Testing Process:  Diagram indicates the process of testing: Input sample of Output (functioning well or Executing Program error discovered) data set • Example 1: Assume that a program to find the average of 3 numbers has been coded. Then, execute the program. Using a few numbers, test the program to verify whether the result is as expected. Testing 1: Input: 4,5,8 Testing 2: From the output, has the program produced the expected result? Input: 7,8,6  An error is known as bug.  Debugging is a process of identifying and correcting error. • Two types of error: 1. Syntax Error (grammatical error)  Occurs when the rules of programming language are not applied.  Correction is done during the program coding.  The bug can be traced during the compilation.  Also known as compile-time error  Must be corrected before executing and testing the program. 2. Logic error  Cannot be traced by compiler. Syntax error will occur if  Corrected during the problem solving process. there is any mistake in the  Also known as run time error. program.  Example output for average is 4, but when it runs, the output is 2. Example: No semicolon at the end of the instruction. Syntax error message Line 9 where syntax error 27 occurred. SYNTAX ERROR
  • 12. F1001 PROGRAMMING FUNDAMENTALS - Logic error is an error that occurs # include <stdio.h> because logical statement in program main( ) is wrong { - Example: int a, b, c, Total; Sum is total of the 3 numbers. double Average; Supposedly the average is sum / 3 Total=0, Average=0 because there are 3 numbers. printf(" Enter 3 numbers:"); scanf("%d %d %d",&a, &b, &c); Total = a + b + c; Average = Total / 6; printf("a = %d b = %d c = %d ", a, b, c); printf("Average is = %f", Average); return 0; Logic Error } The wrong Input three numbers: 444 LOGIC ERROR output Average of the numbers: 2 28
  • 13. F1001 PROGRAMMING FUNDAMENTALS STEP 5: MAINTENANCE Definition: • Activity that verifies whether the operational system is performing as planned or an activity to modify the system to meet the current requirement. • The process of changing a system after it has been applied to maintain its ability. The changes may involve simple changes such as error correcting. How to do maintenance? • By performing activities such as: o Testing – Test the ability of the system. o Measurement – Access data time. Example, time to save, print and others. o Replacement – Replace the old system to new system. o Adjustment – Adding needs to new system. o Repair – For example: An old system cannot update the new data o Updating – Update the database. • Example: Maintenance of Telecommunication System TELEKOM. o Telecommunication System TELEKOM provides communication service from one house to another house. The telephone number is 7 digits. o Assume that management will change the number of digit from 7 digits to 8 digits. o Programmer will change the old system to a new system and test the system whether it is functioning well or not. o Then, the new systems overall capability will be tested. For example, the capability to identify the caller’s and the user’s location and time taken to connect them (measurement) will be tested. o Any old function that is no longer used will be replaced with a new function (replacement). STEP 6: DOCUMENTATION Definition: A written or graphical report of the steps taken during the development of a program. Purpose: It will be useful in the future, in case of modification or maintenance. Content of Documentation: 29
  • 14. F1001 PROGRAMMING FUNDAMENTALS o Description of the program. o Specification of program requirement o Program design such as pseudocode and flowchart o List of program and comments (to explain about the program). o Test results. o User’s manual book. o Program capabilities and limitation. 30