algorithm and flowcharts

21

Upload: sabik-thazhathedhil

Post on 19-May-2015

367 views

Category:

Education


1 download

DESCRIPTION

This will help you to learn about the basics of algorithm and flowcharts.

TRANSCRIPT

Page 1: Algorithm and Flowcharts
Page 2: Algorithm and Flowcharts

GoalsBy the end of this lecture you should …Understand the role of a computer as a tool

in Computer Science.Understand the study of algorithms.Be able to identify how algorithms are

developed & evaluated.Flowcharts

Page 3: Algorithm and Flowcharts

The Computer as a ToolMuch like the microscope does not define

biology or the test tube does not define chemistry, the computer doesn't define Computer Science.

The computer is a tool by which Computer Scientists accomplish their goals – to solve problems.

Page 4: Algorithm and Flowcharts

What is Computer Science?NOT about coding or hardware or software!Computer Science is about PROBLEM

SOLVINGComputer Science is about DEVELOPING

ALGORITHMS to solve complex problems

Page 5: Algorithm and Flowcharts
Page 6: Algorithm and Flowcharts

What is an Algorithm?An algorithm is a well-developed, organized

approach to solving a complex problem.It refers to the logic of the program .It is step by step solution to given problem.

Page 7: Algorithm and Flowcharts

Now a Create Algorithm!! Problem: Dad said you to buy books from a

shop 10km from your house.Step 1: GET THE NAME OF BOOKSTEP2: GET MONEY FROM DADSTEP 3: GET THE ADDRESS OF THE SHOPSTEP4: TAKE BUS TO SHOPSTEP 5: SEARCH FOR THE BOOK IN SHOPSTEP 6: BUY THE BOOK FROM SHOPKEEPER STEP 7: COME BACK TO HOME

Page 8: Algorithm and Flowcharts

Algorithm CharacteristicsPrecise and unambiguousEach instruction should be executed in finite

time.Should not repeat loop for infinite.Correct output.

Page 9: Algorithm and Flowcharts

Developing an Algorithm1. Identify inputs to the system.2. Identify output of the system.3. Identify the process.4. Break the solution to steps.

Page 10: Algorithm and Flowcharts

1. Identify the InputsWhat data do I need?How will I get the data?In what format will the data be?

Page 11: Algorithm and Flowcharts

2. Identify the OutputsWhat outputs do I need to return to the user?What format should the outputs take?

Page 12: Algorithm and Flowcharts

3. Identify the ProcessesHow can I manipulate data to produce

meaningful results?Data vs. Information

Page 13: Algorithm and Flowcharts

4. Break the Solution to steps.By breaking the solution to the steps we can

easily understand the logic of program

Page 14: Algorithm and Flowcharts

Create a program to get name and roll number from user and print it! Step 1: Initialize name as character and roll

number as integerStep2: Display message “ENTER NAME:” on

screenStep 3: GET NAME FROM USERSTEP 4: Display message “ENTER R.NO:”Step 5: GET Roll number from USERSTEP 6: CLEAR THE SCREEN STEP 7: PRINT NAME on SCREEN STEP 8: PRINT ROLL NUMBER on SCREENSTEP 9: STOP

Page 15: Algorithm and Flowcharts

NOW WHAT IS FLOW CHART??

Page 16: Algorithm and Flowcharts

Flow ChartFlow Chart is pictorial representation of an

algorithm.Whatever we have done in algorithm we can

represent it in picture.It is easy to understand.Shows the flow of the instruction

Page 17: Algorithm and Flowcharts

FLOW CHART SYMBOLSOval

Parallelogram

Rectangle

Diamond

Hybrid

Name Symbol Use in Flowchart

Denotes the beginning or end of the program

Denotes an input operation

Denotes an output operation

Denotes a decision (or branch) to be made. The program should continue along one of two routes. (e.g. IF/THEN/ELSE)

Denotes a process to be carried oute.g. addition, subtraction, division etc.

Flow line Denotes the direction of logic flow in the program

/output operations

Page 18: Algorithm and Flowcharts

Example:1

Page 19: Algorithm and Flowcharts

Example 2: ADD 2 INTEGERSSTART

INPUT VALUE OF A and B

SUM=A+B

PRINT :SUM

STOP

Page 20: Algorithm and Flowcharts

Any questions?

Page 21: Algorithm and Flowcharts

Thank You