Download as pdf
Download as pdf
You are on page 1of 13
computers are used to perform a variety of functions. They are being used to generate bills, reserve tickets, make presentations, create documents, play games and so on. Have you ever wondered how a computer knows how to go all this? Software programs are written in computer languages to accomplish these tasks. Aprogram is a set of commands given to the computer to carry out a specific task. However, before we write a program, we must think of the steps required to solve a gven problem. A well written algorithm or flowchart helps us to clearly define the steps and subsequently in the development of good programs. letus learn how to define steps using algorithms and flowcharts. ALGORITHM. 4n algorithm is a list of well-defined steps or instructions to complete a task systematically. Weuse algorithms in everyday life as well. Advantages of Algorithm > An algorithm helps us to think logically to find out the best way to solve a problem and Teach a solution. + in this chapter you will learn: how to define an algorithm. what the advantages of algorithms are. how to define flowcharts. how to identify flowchart symbols. how to draw flowcharts. how to define looping. how to depict looping ina flowchart. \ + Program: Instructions we give to the computer to carry out a specific task. * Algorithm: Directions we give to the computer to carry out a specific task. > A good algorithm helps us to write fe nels and well-organised programs. It is the ae on which the compactness of a progr depends. + Compactness: The characte, of @ computer program igs on which it is written in A program expresses the steps of an algorithm characters as possible, using a programming language. Let us consider a few examples for writing an algorithm. Examples of algorithm Problem 1: To make a chilled mango shake Algorithm: The word algorithm is derived from the name of a Persian mathematician, AlKhwarizmi who worked on algebra, arithmetic, 3. Add milk, sugar and ice cubes. astronomy and solving equations. 4. Switch on the blender. G 4 1. Cut a mango into pieces. 2. Transfer the mango chunks into the blender jar. 5. Blend until the mixture turns smooth and creamy. 6. Pour it into a glass. 7. Garnish the milkshake with almonds and ice cream. 8. Serve cold. Similarly, an algorithm could also be written to list the steps required to solve a problem on a computer. Problem 2: To find the square and cube of a number Algorithm: 1. Accept the number (num). . Calculate the square of a number (num x num). Calculate the cube of a number (num * num x num) 4. Display the square of the number, 5. Display the cube of the number. @ ). lem 3: To find the probl total amount after accepting the price and quantity gorithm: ‘ take the price of the item, 2, Take the quantity of the item, 3, Find the total amount (Price x Quantity). 4, Display the total amount. IT» 4, Write the algorithm to find the average of the total marks scored by a student in three subjects. (Hint: Average = Total of marks in three subjects + 3) 2 Write the algorithm to find the area of a square after acceptin (Hint: Ares i the length of a side. 1 ' FLOWCHART A flowchart is a diagrammatic representation of {Keyword | steps to be taken to solve a problem. A flowchart is ; pictorial in nature and facilitates easy understanding * omen et of the solution. In a flowchart, geometrical shapes taken to solve a problem or or symbols are used to represent the operations and a graphical representation their order is shown by connecting them with arrows. of an algorithm. ‘Flowchart Symbols flowchart is represented by standard symbols. The following table highlights the use of different symbols for drawing flowcharts. = A Terminal box is used to indicate the beginning and the end of a flowchart. It is represented by a rounded rectangle. Start/Stop box or Terminal box Input/Output box Input/Output box is used to accep, Input or display Output. It is represented by a parallelogram, Process box A Process box is used to show actions or processes such as addition and subtraction. A Process box is represented by a rectangle, Decision box A Decision box is used to test conditions and make decisions. 4 condition can either result in a Yes/No or True/False. A Decision box is represented by a diamond shape. Flow Lines Flow Lines are arrows that are used) to connect one box of a flowchart to another. The direction of arrows shows the direction of the flow of information. Connector A flowchart may be long and spat ‘one or more pages. A connector is used to show a jump from one point in the process flow to anotnet It connects different parts of a flowchart that are split between pages. A connector is represented by a circle. gramples of flowcharts problem 1: To buy a red~ plowehart: Colour Ted dress that costs less than Rs 1,000 Flowcharts were introduced by Frank Gilbreth to members of the American Society of Mechanical Engineers (ASME) in 1921. cide the grax Problem 2: To read the marks ofa student and de grade AeCOrRi the following conditions If marks 2 90 then grade is ‘A’. a If marks 2 70 but < go then grade is ‘B- If marks < 70 then grade is . Flowchart: problem 3: Preparea flowchart torn gowonart ake two numbers and display their sum Special software such as Edraw, SmartDraw and Visio are available for drawing flowcharts. r Practice Zone \ Complete the given flowchart. | ltshould take two numbers and display the f ' Sreater number of the two input numbers: 1 tthe two numbers are equal it should display the message ‘Equal Numbers’- LOOPING (Rewer) : a set of Repeating a set of instructions. Loop: el hn cae till a specific condition 1§ inrepeate ‘ly fulfilled is known as looping. i A loop is characterised by two things: > Condition and d > Counter whose valueis increased or decrease in a Let us consider an example of looping 17 flowchart. Consider the given flowchart that displays the word ‘Programming’ five times. The value of Count (counter) is initialised to one. Bay It gets incremented by one every time it displays Cs) the word ‘Programming’. The process of displaying the word and incrementing Count is continued as long as value of Countix less than or equal to 5 (condition). This is known as a loop. The loop comes ty an end when the value of Count becomes 6. Problem 1: To display the table of 2 Flowchart: Using the Connector Symbol : ' | The following is an example where connector! <——— | | : Symbols are used to join flowcharts that span or} ; cover multiple pages. Problem 1 A flowchart is A wellwri 8 dlagremmatic Tepresentation of steps taken to solve a problem. haritten algorithm or fo Special geom, etre i ina flowchart, 8l shapes or symbols are used to represent the operations chart helps us to write good programs. Algorithms are jj sts of well tasks systematically, well-defined steps that help us complete Checklist puta tick (v) against the concept youneed help with. You have understood and a cross (x) against the one that Concept ‘Algorithm: [Ae ————_—_____| ‘Advantages of algorithms Flowchart [symbols of flowcharts Making flowcharts Looping Depicting looping ' got it Tneed help Fill in the blanks. looping connector parallelogram algorithm rectangle 1. The input/output box is represented by a 2 Repeating a set of instructions until a specific condition is fulfilled is known as 3. The process box is represented by @ 4k is used to show a jump from one point in the process flow to another, is to write effective and efficient programs, Agood helps us rr B. Choose and tick the correct answel resent a process? is ust 1. Which of the following symbols 'S : Lp 7 baci 7 ceicamnssa? 2. Which of the following symbols is used to represent conditions in a flowchart? — ia ) 3. Consider the following flowchart. What value will it display? sed to rep aod b 2 « 3 d. No value is displayed Us] real 4, Which of the following symbols is used to connect one box of a flowchart to another. ‘ (CE ——— ——_— a RA is.a set of commands given to the computer to carry out a specific task. a Algorithm b. Flowchart. © Program Symbol Tedisplays the output on the screen. D. Answer the questions in brief. 1. Define an algorithm. What are its advantages? 2. Define flowcharts. State their significance. 3. Define looping. Give an example of looping from real life. Study the image and answer the questions that follow. 1. Identify the terminal box(es) and label them as A. 2. Identify the Input/Output box(es) and label them as B. 3. _ Identify the Process box(es) and label them as C. 4. Is a Decision box being used in the flowchart? If yes, label it as D. wite 2” algorithm “ draw the flowchart to find the difference of two numbers. flowchart to check whett 2 i praw a her the entered number is odd or even. A. Use Word t to type algorithms for the following. 4. To calculate the area and perimeter of a rectangle 3 after accepting its length and breadth (Hint: Area = Length x Breadth, Perimeter = 2 (Length + Breadth) 2. To calculate the circumference of a circle after accepting the radius (Hint: Circumference = 2 x 3.14 x radius) 3. To accept the age of a person and check whether he is eligible to vote or not (Hint: Eligibility to vote is that the age should be greater than or equal to 18)

You might also like