Virtual University ENG 101 Lesson 21 PDF
Document Details
Uploaded by QuietEnlightenment5055
Virtual University
Dr.Surriya Shaffi Mir
Tags
Summary
This document is a lesson on flowcharting in programming. It discusses the importance of flowcharts in program development and provides examples of different flow chart symbols and types.
Full Transcript
Virtual University ENG 101 Lesson -21 Dr.Surriya Shaffi Mir 1 In today’s lesson we will read about presenting information graphically through a flowchart. We will do exercises based on flow charts and read about constructing flow charts....
Virtual University ENG 101 Lesson -21 Dr.Surriya Shaffi Mir 1 In today’s lesson we will read about presenting information graphically through a flowchart. We will do exercises based on flow charts and read about constructing flow charts. 2 Flowcharting So far we have dealt mainly with computers, but now it is imperative that we find out how a program is written. In all activities involving computers, it is necessary that the programmer is aware of what the machine is doing and what a program is supposed to do. As previously mentioned; flowcharting, one of the steps in programming, indicates the logical path the computer will follow in executing a program; it is a drawing very much like a road map. Flowcharting is not restricted to the preparation of programs in a particular language and should be done for each major problem before the writing of the program is attempted. 3 If the finished program does not run as it should, the errors are more easily detected on the flowchart than in the maze of words, characters, and numbers that make up the computer program. In order to develop a flowchart successfully, a programmer should be aware of the sequence of steps needed to obtain a correct solution to a problem. There are two ways of making a flowchart: the freehand version and the neater, more readable version. In the former version, the graphic outlines are simply jotted down as the steps of the program are worked out. This is quite satisfactory if the flowchart is not intended to be kept as a permanent record. However, if a permanent, neater and more readable flowchart is needed, the latter4 Method whereby a template, a sheet of plastic with all the flowcharting symbols cut into it, is used. The following symbols should be used for the purpose of uniformity. The first and last symbol is. This is terminal symbol which indicates the beginning or the end of a program. The word ‘START’ must be inserted inside the figure if it is the beginning of the program and ‘STOP’ if it is the end of the program. The figure in the form of a parallelogram is used as an input/output symbol. It indicates that something is either brought to or taken form the program. The rectangular symbol stands for processing and 5 indicates a place in the program where action is taken. In a program, to indicate that a decision has to be made, the diamond shaped symbol is used. The decision is usually in the form of a question that must be answered by either ‘yes’ or ‘no’. Finally, the arrows are used to show that the flow or direction in which the different actions in the program are performed. It should be noted that flowchart is not a program, but only a step in the preparation of a program, and is used in determining how to step up and write the program. However, if the problem is not understood, 6 neither the flowchart nor the program can be done correctly. It is possible for two programmers working separately, to write programs to solve the same problem and come up with flowcharts and programs that may be altogether different. After a program has been worked out, it is usually written down and kept with a copy of the flowchart along with detailed instructions for the used and interpretation of the program. This procedure is part of what is referred to as program documentation. If documentation isn’t available, it is always possible to work backwards and make a flowchart from an application program. 7 It may be necessary to create a new flowchart when the original one is missing, in order to understand the program for which it was a preparatory step. Flowcharting is one of the first things a student programmer is taught, because a flowchart shows how a person thinks about a problem. In other words it is through this that a new programmer reveals his or her logical and analytical ability, which is a must in programming. 8 Exercises 1. Main Idea Which statement expresses the main idea of the text? Why did you eliminate the other choices? 1. Every programmer must know how to flowchart 2. Program documentation specifies what the program is supposed to do. 3. Flowcharting is a basic step in programming. 9 Exercises 1. Main Idea Which statement expresses the main idea of the text? Why did you eliminate the other choices? 1. Every programmer must know how to flowchart 2. Program documentation specifies what the program is supposed to do. 3. Flowcharting is a basic step in programming. 10 Choices 1 and 2 are both details of choice 3. 2. Understanding the Passage Decide whether the following statements are true or false (T/F) by referring to the information in the text. Then make the necessary changes so that the false statements become true. 1. A good flowchart takes into account the steps which are necessary to solve the problem. 2. It is not possible to draw a flowchart without using a template. 3. There is only one possible flowchart for every problem 11 2. Understanding the Passage Decide whether the following statements are true or false (T/F) by referring to the information in the text. Then make the necessary changes so that the false statements become true. T 1. A good flowchart takes into account the steps which are necessary to solve the problem. F 2. It is not possible to draw a flowchart without using a template. It is possible to draw a flowchart freehand. F 3. There is only one possible flowchart for every problem 12 There is more than one possible flowchart for every problem. 4. Every programmer must learn flowcharting and realize its importance. 5. The method of flowcharting depends on the programming language being used. 6. Flowcharts show the logic one has to follow to solve problem. 7. Documenting a program is essential in explaining what the program is supposed to do. 13 T 4. Every programmer must learn flowcharting and realize its importance. F 5. The method of flowcharting depends on the programming language being used. The method of flowcharting depends on the logical of the programmer T 6. Flowcharts show the logic one has to follow to solve problem. T 7. Documenting a program is essential in explaining what the program is supposed to do. 14 8. If the flowchart is correct, the program will certainly work. 9. Each symbol in flowcharting has a specific meaning. 10. Flowchart can show processes, but not decision. 15 F 8. If the flowchart is correct, the program will certainly work. A correct flowchart and proper coding will ensure that the program will work T 9. Each symbol in flowcharting has a specific meaning. F 10. Flowchart can show processes, but not decision. Flowcharts show processes as well as decisions. 16 3. Locating Information ………..1. A programmer must document his program in order that others may be able to understand it. ………..2. Flowcharting resembles a map. ………..3. Flowcharting shows the logical ability of a programmer. ………..4. There is more than one way of flowcharting. ………..5. A certain symbol is used to indicate if a question is to be answered ‘yes’ or ‘no’. 17 3. Locating Information P.5 ………..1. A programmer must document his program in order that others may be able to understand it. ………..2. P.1 Flowcharting resembles a map. ………..3. P.6 Flowcharting shows the logical ability of a programmer. P.2 ………..4. There is more than one way of flowcharting. ………..5. P.3 A certain symbol is used to indicate if a question is to be answered ‘yes’ or ‘no’. 18 4. Contextual Reference Look back at the text and find out what the words in bold typeface refer to. 1. does not run as it should (l.10)………………. 2. In the former version (l.16)………………. 3. This is quite satisfactory (l.18)………………. 4. the latter method (l.20)…….………… 5. flowcharting symbols cut into it (l.21)……………… 6. which indicates the beginning (l.23)……………… 19 4. Contextual Reference Look back at the text and find out what the words in bold typeface refer to. program 1. does not run as it should (p.1)………………. 2. In the former version (p.2)………………. freehand version 3. This is quite satisfactory (p.2)………………. jotting down graphic outlines 4. the latter method (p.2)…….………… neater, readable version 5. flowcharting symbols cut into it (p.2)……………… sheet of plastic used 6. which indicates the symbol beginning (p.3)……………… 20 7. It indicates that something (l.27)………………. 8. that may be altogether (l.40)………………. different 9. the original one is missing (l.48)……………… 10.which is a must in programming (l.53)……………… 21 7. It indicates that something (p.3)………………. figure 8. that may be altogether (p.4)………………. flowcharts and programs different 9. the original one is missing (p.5)……………… flowchart 10.which is a must in logical analytical ability programming (p.6)……………… 22 5. Understanding Words Refer back to the text and find synonyms for the following words. 1. route (l.6) …………………… 2. try (1.9)…………………… 3. answer (l.14)………………….. 4. put in (l.25)………………….. 5. show (l.52)………………….. 23 5. Understanding Words Refer back to the text and find synonyms for the following words. path 1. route (p.1) …………………… attempt 2. try (p.1)…………………… 3. answer (p.1)………………….. solution 4. put in (p.3)………………….. insert 5. show (p.6)………………….. reveal 24 Now refer back to the text and find antonyms for the following words. 6. unlimited (l.7) …………………… 7. undiscovered (1.11)…………………… 8. temporary (l.19)………………….. 9. inaccessible (l.45)………………….. 10. Illogical (l.53)………………….. 25 Now refer back to the text and find antonyms for the following words. 6. unlimited (p.1) …………………… particular 7. undiscovered (p.1)…………………… detected 8. temporary (p.2)………………….. permanent available 9. inaccessible (p.5)………………….. logical 10. Illogical (p.6)………………….. 26 6. Word forms First choose the appropriate form of the words to complete the sentence. Then check the differences of meaning in your dictionary. 1. involvement, involve, involved, involving a. In most operations …………………….. calculations, computers can do the job much faster than man. b. Flowcharting ……………………… a logical analysis of a problem and a diagrammatic representation of the sequence of events to be followed in solving the problem. 27 6. Word forms First choose the appropriate form of the words to complete the sentence. Then check the differences of meaning in your dictionary. 1. involvement, involve, involved, involving involving a. In most operations …………………….. calculations, computers can do the job much faster than man. b. Flowcharting ……………………… involves a logical analysis of a problem and a diagrammatic representation of the sequence of events to be followed in solving the problem. 28 c. The ……………………… of the new programmer in the user’s group was appreciated by his manager. 2. correction, correct, corrected, corrective, correcting a. It is always a good approach to …………………. the errors in your program before running it with the data. b. In order to develop a good flowchart, a programmer should be aware of the sequence of steps needed to obtain a ……………………… solution to a problem. c. He submitted the ……………………….. version of the program to be keypunched. 29 c. The ……………………… involvement of the new programmer in the user’s group was appreciated by his manager. 2. correction, correct, corrected, corrective, correcting correct a. It is always a good approach to …………………. the errors in your program before running it with the data. b. In order to develop a good flowchart, a programmer should be aware of the sequence of steps needed to obtain a ………………………correct solution to a problem. corrected c. He submitted the ……………………….. version of the program to be keypunched. 30 3. Process, processed, processing a. The Central ……………………….. Unit is responsible for executing the programs. b. A block diagram can show if a ………………….. has to be repeated or if there are alternative routes to be taken. c. The applications of all the new students were ………………………. by the computer. 31 3. Process, processed, processing Processing a. The Central ……………………….. Unit is responsible for executing the programs. b. A block diagram can show if a ………………….. process has to be repeated or if there are alternative routes to be taken. c. The applications of all the new students were processed ………………………. by the computer. 32 4. performance, perform, performed, performing, performer a. ……………………….. is a verb used quite often in COBOL programming. b. Data processing refers to the operations which are …………………….. on the data either to derive information from them or to order them in files. c. The …………………… of the computer salesman was measured by the number of units he sold. 33 4. performance, perform, performed, performing, performer Perform a. ……………………….. is a verb used quite often in COBOL programming. b. Data processing refers to the operations which performed are …………………….. on the data either to derive information from them or to order them in files. c. The …………………… performance of the computer salesman was measured by the number of units he sold. 34 5. documentation, document, documented, documenting a. ………………………. a program is essential so that other programmers can understand it. b. It took the programmer one week to complete the …………………… of the programs in the new system. c. The payroll package we purchased is very well……………………………. 35 5. documentation, document, documented, documenting a. ………………………. Documenting a program is essential so that other programmers can understand it. b. It took the programmer one week to complete documentation the …………………… of the programs in the new system. c. The payroll package we purchased is very documented well……………………………. 36 7a Content Review Try to think of a definition for each of these items before checking them in the Glossary. Then complete the following statements with the appropriate words. Make sure you use the correct form, i.e. singular or plural. executing terminal rectangle template parallelogram diamond documentation 37 1 The information describing what a program can do and what the results mean is referred to as ……………..…………….. 2. It is advisable to test the program without data before………………………………..…it. 3. A piece of plastic with different shapes used for flowcharting is called a …………………………. 4. Data used as input must be indicated with a …………………………………. 5. The symbol which marks the beginning and end of a program is called the …………………….. symbol. 38 1 The information describing what a program can do and what the results mean is referred to as ……………..…………….. documentation 2. It is advisable to test the program without data executing before………………………………..…it. 3. A piece of plastic with different shapes used for template flowcharting is called a …………………………. 4. Data used as input must be indicated with a …………………………………. parallelogram 5. The symbol which marks the beginning and end of a program is called the …………………….. terminal symbol. 39 7b Content Review Problem 1 Study the following flowchart, which shows the procedure followed in calculating an employee’s salary. 40 chart 41 In the following paragraph based on the flowchart above, fill in the blanks with the proper connectives. Use these words: but, that is, then, if, to begin with, after, first, finally, next, before, in other words. In calculating an employee’s salary, a computer must go through a number of operations in a logical manner. ……………….. it must read the number of hours worked and the rate of pay for each hour worked. ………………………….. it must calculate the gross salary; ………………… multiply the hours work by the rate of pay for each hour worked…………...doing these two operations it must find out whether the employee has worked overtime42 In the following paragraph based on the flowchart above, fill in the blanks with the proper connectives. Use these words: but, that is, then, if, to begin with, after, first, finally, next, before, in other words. In calculating an employee’s salary, a computer must go through a number of operations in a logical manner. ……………….. To begin with it must read the number of hours worked and the rate of pay for each hour Then worked. ………………………….. it must calculate that is the gross salary; ………………… multiply the hour’s work by the rate of pay for each hour worked…………...doing after these two operations it must find out whether the employee has worked overtime 43 …………………….. he hasn’t worked overtime the computer prints out the gross salary. ……………….. if the employee has worked overtime, two more operations are necessary ………………… printing out the gross salary. …………………. the overtime pay must be calculated; …………………….. the number of overtime hours must be multiplied by the overtime rate of pay. …………………….. the overtime pay is added to the gross salary. ………………………….. the computer prints out the employee’s salary and stops. 44 …………………….. If he hasn’t worked overtime the but computer prints out the gross salary. ……………….. if the employee has worked overtime, two more operations are necessary ………………… before printing out the gross salary. …………………. First the overtime in other words pay must be calculated; …………………….. the number of overtime hours must be multiplied by the Next overtime rate of pay. …………………….. the overtime pay is added to the gross salary. ………………………….. Finally the computer prints out the employee’s salary and stops. 45 Problem 2. The following flowchart is an example of what many people do before leaving the house everyday. Complete the flowchart by selecting the appropriate event for each step. 46 Chart 2 a. Select jacket b. Warm? c. Select raincoat d. Remove from hanger e. Rain? f. Put on garment g. Check outside h. Select Sweater i. START j. STOP 47 Problem 3 In the chemistry laboratory, all glassware is stored in one cupboard. Your instructions are to go to the laboratory and bring back a 300 ml beaker. Flowchart your activities by completing the flowchart below. 48 a. Replace Chart 3 b. Beaker? c. Return to class d. Locate cupboard e. Remove glass f. Go to laboratory g. 300 ml? h. START i. STOP 49 Problem 4 Peter gets up in the morning, gets washed and dressed. Before having breakfast, he checks if the newspaper has been delivered. If it has, he takes it and puts it in the living room before sitting down to breakfast. After breakfast, he checks to makes sure that he has completed all assigned homework. If there is still some to be done, he does it. Then he checks the clock, and if it is time to go, he leaves for the institute. If not, he reads the newspaper until it is time to go. 50 Flowchart Peter’s activities by completing the flowchart below. a. Read newspaper b. Take in and put newspaper In living room. c. Get up, wash and dress d. Check time e. Newspaper delivered? f. Go to institute g. Time to go? h. Any homework? i. Have breakfast j. Complete homework k. START l. STOP 51 8. Focus Review Focus on: Cause and Effect Read again ‘Flowcharting’ to complete the table below 52 PARA CAUSE EFFECT (1) if the finished program does not run as it should (2) this is quite satisfactory if a permanent, neater and more readable flowchart is needed (3) the word ‘start’ must be inserted inside the figure If it is the end of the program Neither the flowchart nor the (4) program can be done correctly (5) If documentation isn’t available Flowcharting is one of the first (6) things a student programmer is taught 53 PARA CAUSE EFFECT if the finished program does not run the errors are more easily (1) as it should detected on the flow chart If the flowchart is not intended to (2) this is quite satisfactory be kept as a permanent record if a permanent, neater and more The latter method is used readable flowchart is needed (3) If it is the beginning of the program the word ‘start’ must be inserted inside the figure ‘stop’ must be inserted inside the If it is the end of the program figure If the problem is not understood Neither the flowchart nor the (4) program can be done correctly It is always possible to work (5) If documentation isn’t available background Flowcharting is one of the first because a flowchart shows how a (6) things a student programmer is person thinks about a problem 54 taught FOCUSSING Making predictions A prediction is a statement about a particular subject which is related to a prior condition being fulfilled. It is a special kind of inference in which we tell in advance what we think will happen in the future. It is therefore impossible to predict without having any knowledge of an existing condition. 55 By examining existing data, a logical conclusion can often be logically drawn about what is likely to happen next. Predictions of results based on existing conditions can be expressed as different levels of certainty. They are not absolute, and can change according to context. For example 56 1. Certainly (100%) can be expressed by: will (definitely, certainly) certain, sure without a doubt, without question 2. Probability (75% - 90%) can be expressed by probable, probably (75%) like (75%) most probable, most probably, highly probable, most likely, highly likely (90%) 57 3. Possible can be expressed by: may (not), might (not) can, could, possible, possibly, perhaps 4. Improbability (25%), 10%) can be expressed by: improbable, unlikely (25%) doubtful, questionable (25%) probably not (25%) most/highly improbable. unlikely (10%) most/highly doubtful questionable (10%) most probably not 10% 58 5. Impossibility (0%) can be expressed by: a. present or future cannot, could not not possible, impossible b. past could not not possible, impossible 59 When a necessary condition exists in process, the following expressions are used: For Y to occur/happen/take place {x must be present or there must be Y Y depends on X In a condition-prediction relationship, the statement of condition is preceded by ‘if’; no matter to what degree of certainty the prediction is expressed. Also the verb tenses are important to note because a distinction between the statement of condition which is made in the present must relate to the events of the prediction which will happen in the future. 60 Example 1. At the rate computer technology is growing, today’s computers might be obsolete by 2005and most certainly by 2010. CONDITION PREDICTION At the rate computer today’s computers might technology is growing be obsolete by 2005 and most certainly by 2010 61 2. If we couldn’t feed information in and get results back, computers wouldn’t be of much use: CONDITION PREDICTION If we couldn’t feed computers wouldn’t be of information in and get much use results back, 3. If the hammer in drum printers hits a little early or late, the characters will appear slightly above or below the line. CONDITION PREDICTION If the hammer in drum the characters will appear Printers hits a little early slightly above or below or late. the line 62 Exercise 1 Read the following sentences and underline the part that expresses a condition, once; and the part expressing a prediction, twice. 1. It has been said that if transport technology had developed as rapidly as computer technology, a trip across the Atlantic Ocean today would take a few seconds. 2. Working for the U.S. Census Bureau, Dr. Hollerith realized that unless some means of speeding up the analyses of census data were found, it would take more than ten years to complete the job. 63 Exercise 1 Answer Slide Read the following sentences and underline the part that expresses a condition, once; and the part expressing a prediction, twice( is in italics) 1. It has been said that if transport technology had developed as rapidly as computer technology, a trip across the Atlantic Ocean today would take a few seconds. 2. Working for the U.S. Census Bureau, Dr. Hollerith realized that unless some means of speeding up the analyses of census data were found, it would take more than ten years to complete the job. 64 3. If the hammer in train printers hits a little early or late, the character will appear slightly to the right of its proper position. 4. Mainframes would still be occupying a lot of space if it weren’t for microminiaturization. 5. If computer technology continues growing at the rate it has, bubble memory will soon replace the chip. 65 3. If the hammer in train printers hits a little early or late, the character will appear slightly to the right of its proper position. 4. Mainframes would still be occupying a lot of space if it weren’t for microminiaturization. 5. If computer technology continues growing at the rate it has, bubble memory will soon replace the chip. 66 In today’s lesson we read about flowcharting. Followed by comprehension exercises, scanning for information vocabulary exercise and content review exercises. We explored through exercises the relationship between Cause and Effect. Finally we looked at how to make predictions. What language to use for making predictions. With this we come to the end. ALLAH HAFIZ 67