Algorithm and Flowcharts

Post on 19-May-2015

345 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

Transcript

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

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.

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

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.

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

Algorithm CharacteristicsPrecise and unambiguousEach instruction should be executed in finite

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

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

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

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

3. Identify the ProcessesHow can I manipulate data to produce

meaningful results?Data vs. Information

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

easily understand the logic of program

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

NOW WHAT IS FLOW CHART??

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

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

Example:1

Example 2: ADD 2 INTEGERSSTART

INPUT VALUE OF A and B

SUM=A+B

PRINT :SUM

STOP

Any questions?

Thank You

top related