MELJUN CORTES Flowcharting Lecture Notes

11,704 views

Published on

MELJUN CORTES Flowcharting Lecture Notes

Published in: Technology

MELJUN CORTES Flowcharting Lecture Notes

  1. 1. Introduction to ComputerMELJUN CORTES
  2. 2. Computer System
  3. 3. ELEMENTS OF COMPUTER SYSTEM HARDWARE – PHYSICAL COMPONENT OF THE COMPUTER SYSTEM – TANGIBLE PARTS SOFTWARE – PROGRAMS THAT DIRECT THE OPERATION OF THE COMPUTER PEOPLEWARE – THE USERS OF THE COMPUTER
  4. 4. Computer Hardware
  5. 5. HARDWAREINPUT HARWARE PROCESS DEVICES HARDWARE KEYBOARD DEVICE SCANNERS  CPU POINT & DRAW  MOTHERBOARD DEVICES(MOUSE,  VIDEO CARD JOYSTICK,TRACK  SOUND CARD BALL, ETC)  EXPANSION SLOT
  6. 6. HARDWAREOUTPUT STORAGE HARDWARE HARDWARE DEVICE DEVICE MONITOR  MAGNETIC TAPE PRINTER  HARDDISK PLOTTER  FLOPPY DISK ON-SCREEN  COMPACT DISK PROJECTOR  DVD
  7. 7. HARDWARETELECOMMUNICATI OTHER HARDWARE ON HARDWARE  UNINTERRUPTIBL LAN CARDS E POWER SUPPLY(UPS) TRANSMISSION  A STANDBY CABLES(COAXIAL BATTERY CABLE,FIBER POWERED OPTIC,SATTELLIT SOURCE USE IN ES) CASE OF POWER INTERRUPTIONS
  8. 8. Computer Software
  9. 9. Computer Software GENERAL-PURPOSE SOFTWARE – PROVIDES THE FRAMEWORK FOR A GREAT NUMBER OF BUSINESS,SCIENTIFIC, AND PERSONAL APPLICATIONS APPLICATIONS SOFTWARE – DESIGNED AND WRITTEN TO PERFORM SPECIFIC BUSINESS,SCIENTIFIC PROCESSING TASKS SUCH AS INVENTORY OR TAX PREPARATION
  10. 10. Computer Software SYSTEM SOFTWARE – INDEPENDENT OF ANY GENERAL- PURPOSE SOFTWARE PACKAGE OR ANY SPECIFIC APPLICATION AREA – CONTROLS OR IN SOME WAY SUPPORTS SOFTWARE IN THE OTHER TWO CATEGORIES
  11. 11. EXAMPLES OF GENERAL- PURPOSE SOFTWARE WORD PROCESSING SOFTWARE – MS WORD,AMI-PRO,WORDSTAR, ETC. ELECTRONIC SPREADSHEETS – MS EXCEL,LOTUS 123,QUATTRO, ETC. DESKTOP PUBLISHING – PAGEMAKER,VENTURA ETC.
  12. 12. EXAMPLES OF GENERAL PURPOSE SOFTWARE GRAPHICS /PRESENTATION SOFTWARE – PHOTOSHOP,PAINT, COREL DRAW,MS POWERPOINT, PRINTSHOP,BANNER MANIA, DATABASE SOFTWARE – DBASE,FOXBASE,FOXPRO,CLIPPER ETC.
  13. 13. EXAMPLES OF APPLICATION SOFTWARE THESE ARE PROGRAMS OR SYSTEMS DEVELOPED THRU DIFFERENT PROGRAMMING LANGUAGES INVENTORY SYSTEM, POINT-OF-SALE SYSTEM, ENROLLMENT SYSTEM, BILLING SYTEM, PAYROLL SYSTEM, SCHEDULING OR APPOINTMENT SYSTEM ETC.
  14. 14. TYPES OF SYSTEM SOFTWARE OPERATING SYSTEM – DISK OPERATING SYSTEM(DOS) , WINDOWS OS & XENIX FOR MICRO COMPUTERS – UNIX FOR MINICOMPUTER & MAINFRAME COMPUTERS – IBM’S MVS & VM – DEC’S VMS – AT&T’S UNIX
  15. 15. TYPES OF SYSTEM SOFTWARE PROGRAMMING LANGUAGES – COMPILERS & INTERPRETERS – 1ST GEN. OF PROGRAMMING LANGUAGES(MACHINE LANGUAGE) – 2ND GEN. OF PROGRAMMING LANGUAGES(ASSEMBLY LANGUAGE) – 3RD GEN. OF PROGRAMMING LANGUAGES(PROCEDURE ORIENTED)  COBOL,BASIC,PASCAL,C, ETC
  16. 16. PROGRAMMING LANGUAGES 4TH GEN. OF PROGRAMMING LANGUAGES(OBJECT-ORIENTED) – VISUAL BASIC,VISUAL FOXPRO,VISUAL C++, ETC. 5TH GEN. OF PROGRAMMING LANGUAGES – ARTIFICIAL INTELLIGENCE – NATURAL LANGUAGES
  17. 17. OTHER TYPES OF SYSTEM SOFTWARE DATABASE MANAGEMENT SYSTEM SOFTWARE(DBMS) – SQL,INFORMIX,ORACLE, ETC. UTILITY PROGRAMS – NORTON DISK DOCTOR(NDD),PC TOOLS PERFORMANCE MONITORING SOFTWARE COMMUNICATIONS SOFTWARE
  18. 18. OTHER SOFTWARE GAMES VIRUS – BOOT-SECTOR,TROJAN HORSE,MACRO ANTI-VIRUS PROGRAMS(VACCINES) BROWSERS – NAVIGATOR, INTERNET EXPLORER
  19. 19. PEOPLE WARE ORGANIZATION MANAGEMENT – MIS HEAD,EDP HEAD, MIS PLANNER,CHIEF INFORMATION OFFICER(CIO) – PLAN,ORGANIZE,CONTROL,STAFF,DI RECT,BUDGET ETC.
  20. 20. PEOPLEWARE ANALYSIS & DESIGN – SYSTEM ANALYSTS PROGRAMMING – PROGRAMMER(SYSTEM OR APPLICATION) – TRAINEE/JR./SR. PROGRAMMER NETWORK ADMINISTRATION – NETWORK ADMINISTRATOR – DATA BASE ADMINISTRATOR
  21. 21. PEOPLE WARE OPERATIONS – COMPUTER OPERATOR – COMPUTER LIBRARIAN – COMPUTER ENCODER ETC. TECHNICAL SUPPORT – COMPUTER TECHNICIAN EDUCATION & TRAINING – TRAINORS
  22. 22. Computer Languages
  23. 23. Programming Languages  A programming language is a set of rules that provides a way of telling a computer what operations to perform.
  24. 24. Generations ofProgramming Languages  There are several generations of programming languages:  Machine  Assembly  High-level  Very high-level  Natural
  25. 25. Major Programming Languages There are several languages with which to write your program: • FORTRAN • C • COBOL • C++ • BASIC • Java • Pascal • Object-Oriented
  26. 26. Program Logic Formulation
  27. 27. Definition of Programming Programming Computer process data under the control of set of instructions. Programmer Computer program guide the computer through orderly sets of actions by people.
  28. 28. Programming Cycle The computer is basically aproblem-solving tool. Once it isproperly provided with a validprogram, the computer becomes self-operational, that is, it requires nohuman intervention during processing. To use this tool effectively, theprogrammer usually have to performthe following set of well define steps.
  29. 29. Programming Cycle Defining the Problem One of making sure what was has to be done or what problem has to be solved. A careful analysis of that need should involved both prospective users of the information and one or more trained systems designers or programmers, who can perceive the full nature of the information need and how the computer can be used to respond to it.
  30. 30. Planning the Solution This is the next step, after the problem has been defined, select the best method for solving the problem. This commonly involves determining the sequence of processing steps within individual programs.
  31. 31. To save on time and effort, theprogrammer refers to a pictorialrepresentation, the program flow chart.The flow chart is an all-purpose tool and aprogram blueprint. The programmerconstructs the flow chart to lay out theprogram logic.
  32. 32.  Coding the Solution Once the programmer is satisfied that all processing steps have been identified and all alternatives and exceptions provided for, the program is then made. The program flow chart serves as a guide in coding. Checking out the Program Experience will prove that a program seldom executes successfully the first time. Even the simplest programs contain errors, and even experienced programmers make mistakes.
  33. 33.  Documentation After a program has been fully tested and implemented, the programmer must write up the full specifications for all users. The technical documentation package should include: 1. Complete statement of the problem. 2. Description of the program logic and copies of the flow charts. 3.Final source listing
  34. 34. 4. List and description or error tests along with the disposition of these error. 5. Operating instructions, including program and data structures, and test data used. 6. Input and output specifications. 7. Schedules to be maintained. If all the pertinent data is contained withinthe documentation package, then the programcan be run and modified without requiring theoriginal programmer’s assistance.
  35. 35. The Programming Cycle Write up the full DOCUMEN specifications for other TATION program usersDefining what DEFININGhas to be done or THEwhat problem PROBLEMhas to be solved Perform CHECKING debugging OUT THE and testing the PLANNING PROGRAM THE program, SOLUTION using representative CODING s input dataSelect the best method for THEsolving the problem SOLUTION Prepare the set of instructions for the computer to execute
  36. 36. Program Design Tools: Flowchart A flowchart is a pictorial representation of a step-by-step solution to a part of a problem.
  37. 37. Flowchart Basics  A flowchart consists of arrows to represent direction the program takes and boxes and symbols to represent actions.
  38. 38. Pseudocode Pseudocode is an English-like nonstandard language. It allows programmers to focus on the program logic without being concerned about the particulars of a formal programming language.
  39. 39. Algorithms An algorithm is a logical sequence of steps leading to the solution of ONE TASK in a bigger problem – Define expected OUTPUT – Describe desired INPUT – Determine PROCESSING needed to produce desired output from expected input
  40. 40. Sample ProblemWhat tasks need to be done? Add Number 1 and Number 2 – Inputs/Outputs? – Process? Subtract Number 2 from Number 1 – Inputs/Outputs? – Process?
  41. 41. Use Modularity for Design Break the problem into separate tasks For EACH task – What are the inputs (if any)? – What are the outputs (if any)? – What process must be done? Construct pseudocode or flowchart
  42. 42. Flowcharting
  43. 43. Types of Flowcharts 1. Program Flowchart It describes graphically in detail the logicaloperations and steps within a program and thesequence in which these steps are to be executed forthe transformation of data to produce the neededoutput.
  44. 44. 2. System Flowchart It is a graphically representation of theprocedures involved in converting data on input mediato data in output form. It illustrates which data is usedor produced at various points in a sequence ofoperation. It portray the interaction among data,hardware, and personnel.
  45. 45. Flowchart Symbols Input/Output Start/Stop Process Connector Flow Lines Decision Flow DirectionPreparation Indicators
  46. 46. Flowcharting Symbols Input/Output Parallelogram• It represents an instruction to an input or an outputdevice. Process Rectangle• This symbol is used to represent a group of programinstructions that perform a processing function of theprogram such as to perform arithmetic operations, or tocompare, sort, etc.
  47. 47. Flowcharting Symbols Decision Diamond• It denotes a point in the program where more thanone path can be taken. It is used to documentpoints in the program where, based upon variableconditions, a branch to alternative path is possible.The particular path that is chosen depends on theanswer to a question or the result of a test which isinserted in the symbols.
  48. 48. Flowcharting Symbols Preparation Hexagon• This symbols used to represent an instruction orgroup in instructions that will alter, or modify aprogram’s course of execution. It is commonlyused to specify operations such as control, indexregister, initialization, switch setting, and inindicating loops.
  49. 49. Flowcharting Symbols Start/Stop Oval• It is used to designated the beginning and the endof a program, or a point of interruptions. Connector Small Circle• This is a nonprocessing symbols which is used toconnect one part of a flowchart to another withoutdrawing flow lines. It denotes an entry or an exit fromanother part of the flowchart and also used to changethe reading sequence of a flowchart on the same page.
  50. 50. Flowcharting Symbols Arrowheads• Used to show the direction of processing or dataflow. These are added to flow lines of a flowchartappears confusing in its layout.
  51. 51. Flowcharting Symbols Horizontal/ Vertical Lines• It is used to show reading order or sequence inwhich flowchart symbols are to be read.
  52. 52. Advantage and Disadvantage of Flowcharts Advantage of Flowcharts 1. Since flowcharts are language-independent, they can be learned and applied without formal knowledge of a programming language. 2. It enforces users to give attention to significant matters over the less significant ones.
  53. 53. 3. Being graphically portrayed, flowchartsprovide an alternative to the usual narrativedescription of a system or a program. 4. Flowcharts are easier to understand than aprogram written in a particular programminglanguage.
  54. 54.  Disadvantage of Flowcharts 1. Flowcharts do not represent a programming and are more of a person-to person than a person-to- computer means of communication. A computer cannot accept a program describe in flowcharting. 2. Since thinking in graphic term is not normal, flowchart cannot be viewed as a natural means of
  55. 55. 3. Certain details often require long sequence ofinterconnected symbols which could easily bedescribed in just a few lines of explanation. 4. It does not convey why a given set ofoperations is made. Flowcharts only portray how. 5. Flowcharts do not highlight the importantdetails since each step receives as much attention in aflowchart as any other.
  56. 56. Two flowcharts neededTask 1 Task 2 Start Start Get Get Number 1 Number 1 Inputs Get Get Number 2 Number 2 Result = Result = Number 1 + Number 2 Process Number 1 - Number 2 Display Result Outputs Display Result End End
  57. 57. Sample Problem
  58. 58. Example 1 - Algorithms Algorithms for changing a flat tire1. Jack up the car2. Unscrew the lugs3. Remove the wheel4. Put on the Spare5. Screw the lugs6. Jack the car down
  59. 59. Example 1 - Flowchart Flowchart for changing a flat tire. Start A Put on the spare Jack up the Car Screw on the lugs Unscrew the lugs Remove the wheel Jack the Car down A End
  60. 60. Example 2 Given the three numbers A, B, C. Draw a flowcharts to compute and print out the sum, the average, and the product of these values.
  61. 61. Example 2 - Algorithms1. Read in the values of A, B, C.2. Determine the sum of the three values read.3. Compute the average by dividing the sum by 3.4. Multiply the first value by the second value then by the third value to determine the product of the three values.5. Print out the computed values (sum, average, and the product).
  62. 62. Example 2 - Flowchart A Start Ave = Sum/3 Read A, B, C Prod = A*B*CSum = A+B+C Print Sum Ave, Prod A End
  63. 63. Decision Making – Sample Problem
  64. 64. Example 3 The ABC Manufacturing Company plans to give a year-end bonus to each of its employees. Make an algorithms which will compute the bonus of an employee. Consider the following criteria: If the employee’s monthly salary is less than 1,000.00 pesos, the bonus is 50% of the salary; for the employees with salaries greater than 1,000.00 pesos, the bonus is 1,000.00. Print out the name and corresponding bonus of the employee.
  65. 65. Example 3 - Algorithms1. Read in the employee’s name and salary2. Test if the employee’s salary is less than 1,000.003. If the salary is less than 1,000.00 pesos, the bonus is 50% of the employee’s salary. However, if the salary is more than 1,000.00 pesos, the bonus is 1,000.00 pesos.4. Print out the employee’s name and bonus.
  66. 66. Example 3 - Flowchart A Start Bonus = .5 Y Is Salary N Read Bonus - Salary < 1000 Name, = 1000 Salary B Print Name. B A Bonus End
  67. 67. Example 4 Given two numbers X and Y. Draw a flowchart to determine the difference between X and Y. If X-Y is negative, compute R=X+Y, if X-Y is zero, compute R=2X+XY; and if X-Y is positive, compute R=X*Y. Print out the values of X, Y, and R.
  68. 68. Example 4 - Algorithms1. Read in the values of X and Y2. Subtract Y from X3. If the difference between X-Y is negative, compute R=X+Y, if zero, compute R=2X+XY; and if X-Y is positive, compute R=X*Y.4. Print out the values of X, Y and R.
  69. 69. Example 4 - Flowchart Start A Read <0 >0 X, Y R = X+Y If Diff R = X*Y B =0Diff = X - Y Print X, B R = 2X+2Y Y, R A End B
  70. 70. Example 5 Create a Flowchart and algorithms that would input five values of numbers and compute for the average. If the average is below 75, the remarks is failed, if not remark is passed. Print the average, remarks.
  71. 71. Example 5 - Algorithms1. Read in the values of n1, n2, n3, n4, and n52. Compute the average of the five values read.3. If the the average is below 75, the remark is failed, if not the remark is passed4. Print out the average and the remarks.
  72. 72. Example 5 - Flowchart Start A Read n1, Is n2, n3, Y Rem = N Rem = n4, n5 average Failed Failed <75 ave =(n1+n2+n3+n4+ Print Ave, n5)/5 Rem A End
  73. 73. Loop and Counter
  74. 74. Steps in Control Loop Initialization - the value of a counter used is initially set equal to zero ( or one ). This process is always done outside the loop. Test for Limit Conditions - before logic flows gets out of a loop, a loop-terminating condition must first be satisfied. The process of testing is usually found either at the beginning or at the end of a loop. Incrementation - after each loop is executed, 1 is added to the counter. Thus the counter reflects the number of times the operation has been performed. Note that process of incrementation is always done within the loop.
  75. 75.  Looping - is used when it is desired to make the same calculation on more than one set of data. - it consists of repeating a program, or a section of a program, and substituting new data for each repetition. Counters - is set up in a program loop to keep track of the number of times the program segment is repeated. - the program can then be terminated after the completion of a predetermined number of passes. - Prior to the execution of counting, all counters should be initialized ( usually to zero) before the loop is executed.
  76. 76. - For instance, if a program is supposed to readand print five data values, a counter may be setup in the program which counts the number ofdata values; after a data value is read and printed,the counter is increased by one. Before a newdata value is allowed to be read, a conditionaltransfer may be used to determined whether ornot the desired amount of data has been reached.If it has, the program is terminated; otherwise anunconditional transfer causes the computer torepeat the input/output and other processingoperations.
  77. 77. Example 1 The initial value of the radius of a circle is equal to one unit and each succeeding radius is one unit greater than the value before it. Draw a flowchart to compute the area of the circle starting with R=1.0 up to R=5.0, then print out each radius and the corresponding area of the circle.
  78. 78. Example 1 - Algorithms1. Initialized the value of R to 1 and the value of PI to 3.14162. Compute area by multiplying PI by the square of R.3. Print out the value of R and the square of R.4. Increment the value of R by 1.5. Test if R is less than or equal to 56. If R is less than than or equal to 5, loop back and repeat step 2 through 5. However, if R is greater than 5, stop processing.
  79. 79. Example 1 - Flowchart A Start R = 1.0 Print R, PI = 3.1416 AREAB AREA = PI *R*R R = R + 1.0 A Y Is R < = N B 5.0 ? End
  80. 80. Example 2 Given a set of 5 numbers that include both positive and negative data values. Draw a flowchart to read in these values one at a time and count the number of positive values (including zero values) and the number of negative values found in the set. After the required values are determined, print out these counted values.
  81. 81. Example 2 - Algorithms1. Set up two counters and initialized their values to zero (one counter, NNEG, is used for counting the number of negative values and the other, NPOS, for counting positive values).2. Input the first data value, NO.3. Test and determine if the the value read is positive or negative (The decision symbol is used and in it is written the question, NO<0?)4. If the value of NO is negative ( or less than zero), increment the NNEG counter by one. However, if it is positive ( or equal to or greater than zero), increment the NPOS counter.
  82. 82. Example 2 - Algorithms5. Determine the number of values encountered (NVAL) by adding the two counters (NNEG and NPOS).6. Test if NVAL is equal to 57. If the value of NVAL is not equal to 5, repeat steps 2 through 5. However, if it is equal to 5, print out the current value stored in these counters (NNEG and NPOS)
  83. 83. Example 2- Flowchart A Start NNEG = Y Is NO N NPOS = NNEG = 0 NNEG + 1 <0 NPOS + 1 NPOS = 0B NVAL = NNEG + NPOS Read NO Is NNEG, N Y B NVAL = 5? NPOS A End
  84. 84. Example 3 Draw a flowchart and algorithms which will read and print the names and individual scores of 100 students for a particular examination. Also, determine their average and score, and print it out.
  85. 85. Example 3 - Algorithms1. Initialize the counter (CTR) and accumulator (sum) to zero.2. Read in the student’s name and score.3. Print out the student’s name and score.4. Accumulate the data value (SCORE) into the sum.5. Test if the desired amount of data (100) has been reached.6. If the value of counter (CTR) is less than 100, repeat the steps 2 through 5. However, if the desired amount of data has been reached (100), compute the average score by dividing the sum by the value of counter.
  86. 86. Example 3 - Algorithms7. Print out the average scores.
  87. 87. Example 3 - FlowchartStart ACTR = 0 SUM = SUM + SCORESUM = 0 BRead Ave = Y Is CTR N CTR = CTR + 1Name, SUM/CTR = 100?SCORE Print B Ave A End
  88. 88. Example 4 Given the lengths of 3 sides (a, b, and c) of a triangle. Prepare a flowchart to read these values, compute the perimeter and the value of S, and determine the area of the triangle using Hero’s formula (Hint: Per = a + b + c; S=Per/2; and the AREA=[s(s-a) (s-b) (s-c)]2. Then print out the given and computed values.
  89. 89. Example 4 - Flowchart Start ACTR = 0 Perimeter = a + b + c CRead Is Y Printa, b, c Per < CTR 0? A 1
  90. 90. Example 4 - Flowchart 1 B N Is Print S = Per/2 End Area = 0 ? a, b, c Per, S, AreaArea = s(s-a) (s-b) (s-c) CTR = CTR + 1 B C
  91. 91. Loop and Accumulator
  92. 92. •Accumulator The variable used is therebycontinuously accumulating the numericalquantities
  93. 93. Example 1 Draw a flowchart to compute and print the sum of the squares of positive integers from 1 to 100.
  94. 94. Example 1 – Flowchart-Sol 1- K<=100 Start A K=1 Sum = 0 B Is Y N K=k+1 Print B k<=100? sum Sum = Sum + 1 End A
  95. 95. Example 1 – Flowchart-Sol 2 – K=100 Start Print Is Y N sum K =100? K=K+1 K=1 Sum = 0 B End BSum = Sum + K2 A
  96. 96. Example 1 – Flowchart-Sol 3 – K>100 Start A N K=1 Sum = 0 Sum = Sum + K2 B Is Y Print K > 100? sum K=k+1 End B A
  97. 97. Example 2 Make a flowchart that will display the numbers from 1 – 5.
  98. 98. Example 2 - Flowchart Start A A=1 Print A F A=A+1B If A < End = 10 ? T B A
  99. 99. Example 3 Draw a flowchart to compute and print the sum of the square of positive integer from 1 - 5
  100. 100. Example 3 - Flowchart Start A X=1 A=A+1 Sum = 0 F Print If A <Sum = Sum + B Sum =5? (A * A) T End A B
  101. 101. Example 4 Create a flowchart that will print the product numbers from 1 - 5
  102. 102. Example 4 - Flowchart Start A A=1 Prod = A * Prod Prod = 0 A=A+1 F Print If A <B Prod =5? B T End A

×