Basic Computing/ Computer        Orientation     Lecture 8, 9 & 10     by Sara Hassan
Chapter 8Computer Programming Fundamentals
The Problem-Solving Process          Input        Processing          Output
Program   A program is the set of instructions that instruct the computer    about the way the task is to be performed. ...
Program Planning 1.   Analyze 2.   Design 3.   Code, Test and Debug 4.   Complete the Documentation
Program Development Lifecycle          Chapter-8: Computer Programming Fundamentals   6
Algorithm Ordered sequence of finite, well defined, unambiguous  instructions for completing a task. English-like repres...
Algorithm: An Example          Chapter-8: Computer Programming Fundamentals   8
Control Structures Specifies statements to be executed and order of  execution of statements     Execution of a statement...
Flowchart   Diagrammatic representation of logic for solving task   Drawn using boxes of different shapes with lines con...
Flowchart symbols         Chapter-8: Computer Programming Fundamentals   11
Elements of Flowcharts     Symbol     Name                Flowline                Terminal                Input/Output    ...
Continued…     Symbol   Name              Connector              Off page Connector              Predefined process       ...
Preparing a Flowchart Common symbols that are used to draw a flowchart     Process, Decision, Data, Terminator, Connector...
Control Structures in Flowchart           Chapter-8: Computer Programming Fundamentals   15
Preparing a Flowchart (contd..) Sequence: Steps executed in linear order Selection: Step to be executed next is based on...
Examples of Flowchart                                                                   Can you                           ...
start                     Read                     data        Declare a variable “greatest”      Assign the first value i...
Solving the Break- in - ClassProblemIn order to make the classes        Students       Situation   Break    more productiv...
startShow ofHands for Break 0 <x<5              No break 5 < x <1 5               3 mins15 < x < 25               5 mins25...
Pseudo code   Consists of short, readable and formally-styled English    language used for explaining an algorithm.   Do...
Preparing Pseudo code Written using structured English Commonly used terms to represent actions     Inputting data:   IN...
Control structures for Pseudocode                                                    IF (condition) THEN           WHILE (...
Algorithm, Flowchart, Pseudocode Algorithm: A sequence of instructions used to solve a  particular problem Flowchart and...
Upcoming SlideShare
Loading in …5
×

Computer Chapter 8, 9 & 10

2,096
-1

Published on

Lahore Business School (LBS)

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,096
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
52
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Computer Chapter 8, 9 & 10

  1. 1. Basic Computing/ Computer Orientation Lecture 8, 9 & 10 by Sara Hassan
  2. 2. Chapter 8Computer Programming Fundamentals
  3. 3. The Problem-Solving Process Input Processing Output
  4. 4. Program A program is the set of instructions that instruct the computer about the way the task is to be performed. Instructions in a Program have three parts Accept Input Data that needs to be processed Act upon Input Data and process it Provide Output to user Instructions are defined in a specific sequence Chapter-8: Computer Programming Fundamentals 4
  5. 5. Program Planning 1. Analyze 2. Design 3. Code, Test and Debug 4. Complete the Documentation
  6. 6. Program Development Lifecycle Chapter-8: Computer Programming Fundamentals 6
  7. 7. Algorithm Ordered sequence of finite, well defined, unambiguous instructions for completing a task. English-like representation of logic to solve problem Step-by-step procedure for solving problem For a particular task, different algorithms can be written Select an algorithm based on advantages and disadvantages Different Algorithms would typically lead to trade off between memory requirements and execution speed Chapter-8: Computer Programming Fundamentals 7
  8. 8. Algorithm: An Example Chapter-8: Computer Programming Fundamentals 8
  9. 9. Control Structures Specifies statements to be executed and order of execution of statements Execution of a statement based on a decision Repetitively execute statements unless condition met Used by Flowchart, Pseudo code Three kinds Sequential: Instructions executed in linear order Selection (branch or conditional): Asks true/false question and selects next instruction based on answer Iterative (loop): Repeats execution of block of instructions Chapter-8: Computer Programming Fundamentals 9
  10. 10. Flowchart Diagrammatic representation of logic for solving task Drawn using boxes of different shapes with lines connecting them to show the flow of control Make logic of program clearer in a visual form Diagrammatic representation forms a common medium of communication Drawn using different kinds of symbols. Chapter-8: Computer Programming Fundamentals 10
  11. 11. Flowchart symbols Chapter-8: Computer Programming Fundamentals 11
  12. 12. Elements of Flowcharts Symbol Name Flowline Terminal Input/Output Processing Decision
  13. 13. Continued… Symbol Name Connector Off page Connector Predefined process Annotation
  14. 14. Preparing a Flowchart Common symbols that are used to draw a flowchart Process, Decision, Data, Terminator, Connector and Flow lines Rules – Should have Start and End – Direction of flow must be from top to bottom and left to right – Relevant symbols must be used while drawing a flowchart – Sequence, selection, iterative structures may be used wherever required Chapter-8: Computer Programming Fundamentals 14
  15. 15. Control Structures in Flowchart Chapter-8: Computer Programming Fundamentals 15
  16. 16. Preparing a Flowchart (contd..) Sequence: Steps executed in linear order Selection: Step to be executed next is based on decision taken. Different path followed for True and False Iterative: Condition is checked. Either next step in sequence is executed or control goes back to one of the already executed steps to make a loop Limitations May run into multiple pages, difficult to understand Updating with changing requirements Chapter-8: Computer Programming Fundamentals 16
  17. 17. Examples of Flowchart Can you draw a flowchart to read 100 numbers and print the largest number? Product of Maximum of Sum of firsttwo numbers three numbers 100 integers Chapter-8: Computer Programming Fundamentals 17
  18. 18. start Read data Declare a variable “greatest” Assign the first value in the list to “greatest” Compare the number in “greatest” with next no. in the list Is next no. YES greater than “greatest” ? NO Assign next no. to “greatest”YES Are there more numbers in the list?
  19. 19. Solving the Break- in - ClassProblemIn order to make the classes Students Situation Break more productive and easy who want Duration on the nerves the Admin at a university wants to break formulate the policy on Less than Trivial No break giving breaks in the classes. equal to 5% They have come up with an idea of giving breaks only when they are required by 5 < x ≤ 15 % Fair 3 Min the class students and their Break duration is also to be determined by how much 15 < x ≤ 25% Modest 5 Min severely it is demanded. Break You are required to develop a flow chart to demonstrate 25 < x ≤ 50% Dire 10 Min how the policy is to work. They’ve provided you with or greater Break the following data:
  20. 20. startShow ofHands for Break 0 <x<5 No break 5 < x <1 5 3 mins15 < x < 25 5 mins25 < x <50 10 minsEND
  21. 21. Pseudo code Consists of short, readable and formally-styled English language used for explaining an algorithm. Does not include details like variable declarations, subroutines etc. Short-hand way of describing computer program Not based on any programming language Uses structured constructs of programming language but is not machine readable Cannot be compiled or executed No standard for syntax of pseudo code exists Easily translated into a programming language Chapter-8: Computer Programming Fundamentals 21
  22. 22. Preparing Pseudo code Written using structured English Commonly used terms to represent actions Inputting data: INPUT, GET, READ Outputting data: OUTPUT, PRINT, DISPLAY Calculations: COMPUTE, CALCULATE Incrementing: INCREMENT Control structures – Sequence structure: sequence of steps executed in linear order – Selection constructs: if-statement, case statement – Iterative statements: WHILE, DO-WHILE Chapter-8: Computer Programming Fundamentals 22
  23. 23. Control structures for Pseudocode IF (condition) THEN WHILE (condition) Statement(s) 1 Statement 1 ELSE Statement 2 Statement(s) 2 Step 1 : ENDIF : Step 2 END IF (condition) THEN Statement(s) 1 Step 3 DO ENDIF Statement 1 : Statement 2 CASE expression of : : Condition-1 : statement1 : : Condition-2 : statement2 WHILE (condition) : Condition-N : statement N OTHERS: default statement(s)Sequence Selection Iteration Chapter-8: Computer Programming Fundamentals 23
  24. 24. Algorithm, Flowchart, Pseudocode Algorithm: A sequence of instructions used to solve a particular problem Flowchart and Pseudo code: Tools to document and represent algorithm Flowchart : Graphical representation of algorithm Pseudo code: Readable, formally styled English like language representation of algorithm No knowledge of programming language required to write or understand flowchart or pseudo code Chapter-8: Computer Programming Fundamentals 24
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×