Flowcharts for Programming - Lecture 1 | Prof. Kamal Ghanshala | Graphic Era University

Graphic Era University Official
7 Dec 202019:38

Summary

TLDRThis video script offers a comprehensive introduction to flowcharts, emphasizing their utility in programming for maintaining the sequence of instructions. It explains the significance of sequencing in programs and how flowcharts assist in this process. The script outlines the basic symbols used in flowcharts, such as start/stop, input/output, assignment, decision, and connectors. It illustrates these concepts with examples, including generating bills for mango sales with varying levels of input requirements, and calculating the average of three numbers. The script also highlights the importance of proper syntax in flowchart assignments to ensure accurate program translation.

Takeaways

  • 📝 A flowchart is a diagrammatic representation of a process, useful for maintaining the proper sequence of instructions in programming.
  • 🔢 A program is a set of instructions in a specific sequence, and flowcharts help in visualizing this sequence before writing the actual program.
  • 🏁 Flowcharts start with a 'start' symbol, which is a box rounded at both ends, and end with a similar 'stop' symbol.
  • 📥 The 'input' or 'read' statement in a flowchart represents the values supplied by the user, which are stored in variables like n1, n2, and n3.
  • 📤 The 'print' or 'output' symbol, shown as a parallelogram, is used to display results from the program.
  • 🔄 The 'assignment box', a rectangular symbol, is used for calculations, such as assigning the result of a formula to a variable.
  • ❓ The 'decision box', in a diamond shape, represents a yes/no decision in the flowchart, such as checking if one value is greater than another.
  • 🔗 Connectors are used when continuing a flowchart in a different part of the diagram, represented by a circle with a label inside.
  • 🍋 Examples in the video include generating a bill for mango purchases, where known values or user inputs are used to calculate the total cost.
  • 🔢 Another example includes calculating the average of three numbers inputted by the user, with emphasis on correct syntax when writing equations in programming.

Q & A

  • What is a flowchart?

    -A flowchart is a diagrammatic representation of a process, used in programming to maintain the proper sequence of instructions.

  • Why is sequencing important in a program?

    -Sequencing is important in a program because it ensures that the set of instructions are executed in the correct order.

  • What is the first step in drawing a flowchart?

    -The first step in drawing a flowchart is to write 'start' and then draw a rounded box from both ends to represent the beginning of the process.

  • How is input represented in a flowchart?

    -Input in a flowchart is represented by writing 'input' or 'read' followed by a list of arguments, such as 'n1, n2, n3', which signifies that the user will supply three values.

  • What symbol is used to represent output in a flowchart?

    -Output in a flowchart is represented by a parallelogram, with 'print' followed by the list of arguments whose values are to be displayed.

  • What is an assignment box in a flowchart?

    -An assignment box in a flowchart is a rectangular box used to represent calculations or assignments, such as 'result is equal to a into b plus c'.

  • How are decisions represented in a flowchart?

    -Decisions in a flowchart are represented by a diamond-shaped box, which indicates a yes/no type of decision, such as 'a greater than b'.

  • What is the purpose of a connector in a flowchart?

    -A connector in a flowchart is a circle with a label (like 'x') used to indicate where the flowchart resumes after a jump or loop.

  • How does a flowchart help in generating a bill for Bogilal's mangoes?

    -A flowchart helps in generating a bill for Bogilal's mangoes by diagrammatically outlining the steps to calculate the total cost based on the rate per mango and the number of mangoes bought.

  • What is the significance of a 'stop' symbol in a flowchart?

    -The 'stop' symbol in a flowchart signifies the end of the process or program, indicating where the flowchart concludes.

  • How can a flowchart be used to find the average of three numbers?

    -A flowchart can be used to find the average of three numbers by diagramming the steps to input the numbers, calculate their sum, divide by three, and then print the average.

Outlines

00:00

📊 Introduction to Flowcharts

This paragraph introduces the concept of flowcharts in programming. A flowchart is defined as a diagrammatic representation of a process, crucial for maintaining the sequence of instructions in a program. The paragraph explains that a program is a set of instructions in a proper sequence, and flowcharts are used to visualize and maintain this sequence before writing the actual code. The paragraph also describes the basic elements of a flowchart, such as the start and stop symbols, input and output symbols, assignment boxes, decision boxes, and connectors. The speaker uses examples to illustrate how these elements are used in flowcharts to represent different programming constructs.

05:02

🛒 Flowchart for Generating a Bill

This paragraph delves into the application of flowcharts by demonstrating how to create a flowchart for generating a bill for mangoes sold by Bogilal. The speaker presents three scenarios with increasing complexity: a fixed sale of five mangoes at a fixed rate, a sale where the number of mangoes is variable but the rate is fixed, and a scenario where both the rate and the number of mangoes are variable and need to be input by the user. Each scenario is explained with a corresponding flowchart, highlighting the use of input, calculation, and output steps. The paragraph emphasizes the flexibility of flowcharts in adapting to different program requirements.

10:03

🔢 Flowchart for Calculating Average

The paragraph focuses on creating a flowchart to calculate the average of three numbers. It discusses the need for user input to supply the three numbers and then describes the steps involved in calculating the average. The speaker explains the use of input boxes to gather the numbers, an assignment box to calculate the sum, and another assignment box to compute the average by dividing the sum by three. The paragraph also includes a discussion on the correct way to format calculations in flowcharts to ensure they are represented accurately and can be translated into valid computer statements.

15:05

🔄 Flowchart Simplification and Common Mistakes

In this paragraph, the speaker discusses the possibility of simplifying the flowchart for calculating the average of three numbers by combining steps into a single line. They also address common mistakes made by students when writing calculations in flowcharts, such as not properly enclosing the entire expression in parentheses, which can lead to incorrect calculations. The speaker emphasizes the importance of continuity and proper formatting in flowcharts to ensure they accurately represent the intended program logic.

Mindmap

Keywords

💡Flowchart

A flowchart is a diagrammatic representation of a process or program. In the context of the video, it is used to visually map out the sequence of steps a program follows, ensuring logical flow and proper structure. For example, the instructor draws flowcharts to illustrate how different values like input or calculations are processed in a program.

💡Start/Stop

These are special symbols used in flowcharts to mark the beginning and the end of the process. The 'start' box signals the commencement of the program, and the 'stop' box marks the end. Both symbols are represented as rounded rectangles, as mentioned when the instructor explains how every flowchart begins with 'start' and concludes with 'stop'.

💡Input

Input refers to values that the user provides to a program during execution. In the video, the instructor demonstrates how the input is represented in flowcharts using the example of a program where the user provides values like the number of mangoes or the rate. Inputs are crucial for the flexibility of programs, allowing dynamic behavior based on user data.

💡Output

Output represents the result displayed by the program after processing the inputs. In the flowchart, output is depicted by the 'print' statement inside a parallelogram. For instance, in the flowchart to calculate the total bill for mangoes, the output is the total bill which is displayed to the user.

💡Decision Box

The decision box is used to represent a logical decision in a flowchart, typically asking a 'yes' or 'no' question to direct the flow of the process. In the example from the video, the decision box is used to compare values, such as whether 'A' is greater than 'B'. Based on the result, the flow proceeds in one of two directions.

💡Assignment Box

An assignment box is a rectangle used to represent a calculation or assignment operation in a flowchart. In the video, the instructor demonstrates this by assigning the result of an expression, like 'result = A * B + C', where a computation takes place and the result is stored in a variable. This is essential for performing operations in a program.

💡Connector

A connector is used to link different parts of a flowchart, especially when space is limited. It is depicted as a circle with a label, allowing the flowchart to resume from the point marked by the connector. In the video, the instructor explains how connectors are useful when continuing the flow of a process from one part of the chart to another.

💡Input/Output Box (Parallelogram)

The input/output box, often shown as a parallelogram, is used to represent operations where the program takes in data (input) or displays information (output). For example, the 'input' box is used when the user provides the number of mangoes, and the 'output' box is used to print the calculated bill.

💡Program

A program is defined as a set of instructions executed in a specific sequence. The flowchart helps visualize and maintain this sequence, ensuring the program runs logically. In the video, the instructor provides examples of small programs, such as calculating the total cost of mangoes, that follow a precise sequence from input to output.

💡Calculation

Calculation refers to the mathematical operations performed within the flowchart, such as summing values or computing totals. For instance, the video illustrates a flowchart where the bill is calculated by multiplying the number of mangoes by the rate, demonstrating how programs use basic arithmetic to solve problems.

Highlights

Flowcharts help in maintaining the proper sequence of instructions in a program.

A program is a set of instructions in a proper sequence, and flowcharts help in planning the sequence.

Flowcharts start with a 'Start' box and end with a 'Stop' box, both rounded at the ends.

User input in a flowchart is indicated with an input or read statement, followed by a list of arguments.

The 'Print' command in a flowchart is used to display output values to the user.

Calculations are represented by assignment boxes in rectangular shapes.

Logical decisions are made using decision boxes that allow 'Yes' or 'No' type decisions.

Connectors in flowcharts, marked with circles, help resume the process from a specific point.

Problem example: Bogilal sells mangoes at a fixed price of 10 per mango. The flowchart directly calculates and prints the bill for a known number of mangoes.

In a more flexible flowchart, the user inputs the number of mangoes, and the bill is calculated based on user input.

For variable rates, the user inputs both the number of mangoes and the rate per mango, and the bill is calculated accordingly.

Problem: Find the average of three numbers. The flowchart includes user input for three values, calculation of the sum, and division by 3 to get the average.

The flowchart can be simplified by combining the calculation and input steps into a single line.

Important note: Incorrect formula formatting, such as breaking the average calculation into multiple lines, results in invalid computer code.

The correct approach is to write the entire expression, such as the average calculation, in one continuous line.

Transcripts

play00:05

today we are discussing flowcharts

play00:07

so what is a flowchart first of all let

play00:09

us define a flowchart a flowchart is a

play00:12

diagrammatic representation of a process

play00:16

okay

play00:16

in programming it helps us in

play00:18

maintaining the proper

play00:20

sequence of instructions so first of all

play00:23

let us see what is a program

play00:25

a program is a set of instructions

play00:28

in a proper sequence ok so sequencing is

play00:32

very important in program and for

play00:34

maintaining the sequence

play00:35

before writing the program what we do we

play00:37

draw a flowchart flowchart helps us in

play00:40

maintaining

play00:41

the sequence of a program ok

play00:44

whenever we start drawing a flowchart we

play00:46

write start

play00:49

and then we close start

play00:52

ok to this type of box which is rounded

play00:57

from both the

play00:58

ends see whenever we

play01:01

complete our flowchart we write stop

play01:05

again we draw same type of box which is

play01:08

rounded from

play01:10

ok here and here

play01:14

see whenever user supplies some values

play01:18

to the program which is called input

play01:21

inputting the values okay

play01:24

so what we do we write input or we write

play01:27

read

play01:31

and then we write list of arguments

play01:35

suppose i am writing

play01:36

n one comma n two comma n3

play01:41

it means whenever this program will get

play01:43

executed at that time user will supply

play01:46

you three values

play01:47

okay first value will replace n1 second

play01:49

value will replace

play01:50

n2 and third value will replace n3 okay

play01:54

similarly whenever we want to

play01:57

display something to outside world

play01:59

whenever the programmer wants to display

play02:01

something

play02:02

some result to outside world then what

play02:05

he will be doing he'll be writing

play02:07

print

play02:11

and again list of arguments whose values

play02:15

you want to

play02:17

display ok suppose arguments are

play02:21

a one comma a two comma a three so i

play02:23

will be writing a one

play02:24

comma a two comma a three

play02:28

so whenever this program will get

play02:30

executed

play02:31

the values of a one a two and a three

play02:34

will be printed or will be displayed

play02:37

ok similarly when we have to do some

play02:39

calculation

play02:40

then we draw assignment box ok

play02:44

which is our rectangular box so this is

play02:47

this type of rectangular box is called

play02:50

assignment box

play02:59

suppose i am writing

play03:03

result is equal to a

play03:07

into b plus

play03:11

c so what will happen first of all

play03:15

this a into b plus c will be calculated

play03:19

so this will be calculated and this will

play03:22

be assigned to

play03:23

result okay so this is called assignment

play03:27

box where right hand side gets

play03:28

calculated and gets assigned to

play03:30

left hand side okay

play03:34

now suppose we have to take a decision

play03:36

suppose

play03:38

we are moving in this direction and now

play03:40

we have to take a decision

play03:41

ok logical decision then will be drawing

play03:43

a decision box like this

play03:48

ok suppose this is a logical decision it

play03:52

means ah yes no type of decision

play03:54

h a greater than b

play03:59

ok if it is yes

play04:04

then i am moving in this direction and

play04:06

if it is

play04:07

no then i am moving in

play04:11

this direction because either a will be

play04:13

greater than b or it will be smaller

play04:14

than or equal to

play04:16

b so this is called a decision box

play04:19

at times you require some connectors

play04:22

also

play04:23

ok suppose

play04:28

now i do not have space here so now what

play04:30

will i be doing i will be drawing a

play04:32

connector here suppose i draw a

play04:34

connector it is a

play04:35

circle i draw a connector here and i

play04:38

write

play04:39

x here it means

play04:42

now i will be starting from i will be

play04:45

resuming from

play04:46

x so now if i write x

play04:51

and like this it means whatever i have

play04:53

left here now i am

play04:54

resuming from here so this is called a

play04:57

connector

play04:59

ok so so far we are discussing only

play05:02

these many symbols because so far we

play05:04

wont be drawing loops whenever

play05:06

we draw loops then will be draw we will

play05:09

be discussing

play05:10

some more symbols ok so now let us start

play05:13

drawing some basic flowcharts see our

play05:16

first

play05:16

problem is like this problem number one

play05:19

bogilal sells mangoes at rupees 10

play05:22

per mango mohan bought five mangoes from

play05:26

bogie lal

play05:27

now we have to draw a flow chart to

play05:29

generate bill

play05:31

okay now here we know what is the rate

play05:33

rate is rupees 10 per mangoes how many

play05:36

mangoes

play05:36

one bought five mangoes ok so

play05:40

we will be drawing flow chart like this

play05:42

now we need not to input anything

play05:44

because we already know everything we

play05:45

know the rate we know the number of

play05:47

mangoes so

play05:48

we need not to input anything we will be

play05:50

drawing a flowchart like this

play05:52

start

play06:01

we can directly calculate bill we may

play06:04

write

play06:06

well is equal to rate is 10

play06:10

into number of mangoes is 5

play06:17

and after that once we know the bill

play06:19

then will be printing the value of

play06:21

bill so will be drawing a parallelogram

play06:23

and will be writing

play06:27

print bill

play06:32

ok and after that i am writing

play06:36

stop

play06:44

so whenever a programmer will make a

play06:46

program according to this flowchart

play06:48

ok that program will not input anything

play06:51

whenever that program will get executed

play06:53

it will

play06:54

be directly generating the value of bill

play06:56

and which will always be

play06:58

rupees 50 okay so

play07:02

normally our flow charts are not as

play07:04

simple as this one

play07:06

so let us take one more example

play07:09

next one now let us discuss

play07:12

bit more generalized type of problem

play07:16

problem number two bogilal sells mangoes

play07:18

at rupees 10 per mango

play07:20

okay so rate is fixed draw flow chart to

play07:24

generate

play07:24

bill now if we have to generate well we

play07:27

must know how many mangoes a customer

play07:30

is buying so that is not given it means

play07:32

that will be

play07:33

inputted in our program ok that will be

play07:36

asked from the user whenever this

play07:38

program will get executed

play07:40

that value will be supplied by the user

play07:44

ok so now we have a flexibility earlier

play07:46

we were selling only five mangoes now

play07:49

we may change number of mangoes because

play07:51

the user will decide how many mangoes he

play07:53

has to

play07:54

buy so now we'll be drawing our flow

play07:56

chart like this will write start

play08:04

now we are now deciding number of

play08:06

mangoes number of mangoes

play08:08

will be supplied by the user so we'll be

play08:11

writing

play08:12

input input means user will supply

play08:15

input number of

play08:18

mangoes okay here we may write n m means

play08:23

number of

play08:27

mangoes so input number of mangoes

play08:32

and m and

play08:35

after that we are writing once we know

play08:37

number of mangoes because rate is fixed

play08:40

so what will be our bill our

play08:44

bill will be equal to 10

play08:47

that is the rate and into number of

play08:52

mangoes

play08:56

what do we do after this

play09:01

after this since we have calculated well

play09:05

so we have to display to the outside

play09:07

word so will be using a

play09:08

print statement so

play09:12

what will have will be enclosing it in a

play09:15

parallelogram and then we will write

play09:17

print

play09:21

i'll write print bill so whenever this

play09:24

program will get executed ok because we

play09:26

are drawing flowchart then based on this

play09:28

flowchart

play09:29

what will happen programmer will write

play09:32

program

play09:33

and whenever this program will get

play09:35

executed

play09:36

at that time what will happen ok

play09:39

whenever

play09:40

programmer writes a program according to

play09:42

this flowchart and that program gets

play09:44

executed so

play09:46

at the execution time first of all

play09:49

here the program will ask input number

play09:53

of mangoes so the user will have to

play09:55

supply

play09:56

number of mangoes okay then the program

play09:58

will calculate

play09:59

and then the program will display

play10:03

ok print or display bill ok whatever

play10:06

bill we have calculated that will be

play10:08

displayed to

play10:09

outside work ok that is how this

play10:11

flowchart will work

play10:12

now let us take our problem number 3

play10:14

which is

play10:16

more generalized ah here bogilal is

play10:19

selling mangoes

play10:20

ok because rate may change every day so

play10:23

rate is not given

play10:25

draw flow chart to generate bill so here

play10:28

rate is not given and number of mangoes

play10:30

because number of mangoes will also

play10:32

change from customer to customer so that

play10:34

is also not

play10:35

given so from where will we get rate and

play10:38

number of mangoes

play10:40

so both have to be inputted ok

play10:43

have to be whenever we have to generate

play10:45

build so both these values have to be

play10:47

inputted have to be supplied

play10:49

by the user okay so

play10:53

our flowchart will be like this start

play11:06

now i have to input input

play11:10

first of all number of mangoes

play11:14

and rate

play11:19

okay

play11:26

we may specify what is nm nm is

play11:31

number of mangoes

play11:38

once we know number of mangoes and rate

play11:41

then we can very well find bill

play11:43

what will be our bill

play11:47

bill is equal to number of mangoes

play11:50

into rate ok basically its rate per

play11:57

mango

play11:58

so once we know number of mangoes and

play12:00

rate of mango

play12:01

red per mango then we can always

play12:03

calculate bill is equal to number of

play12:05

mangoes

play12:06

into our rate

play12:11

ok and after that what we do once we

play12:15

know the

play12:16

bill then what we can do we can display

play12:20

parent bill

play12:29

and after that we stop

play12:37

ok so now what happens

play12:41

whenever somebody writes a program

play12:43

according to this flowchart

play12:46

this is small r whenever somebody writes

play12:48

a program according to this flowchart

play12:51

then and see once a program is returned

play12:54

so first of all it is compiled it means

play12:56

it is changed

play12:57

it is translated to machine language ok

play13:00

and after that its

play13:01

loaded and after that you may execute it

play13:05

so whenever this program will get

play13:07

executed so

play13:08

first of all

play13:12

at this point see

play13:15

user need to supply two values ok the

play13:18

program will ask user to supply

play13:20

two values at this point number of

play13:22

mangoes

play13:23

and rate per mango okay based on

play13:26

these two values the bill will be

play13:28

calculated

play13:30

and once bill will is calculated the

play13:32

value of bill will be

play13:34

printed here okay so now if some user is

play13:38

executing this program so he need to

play13:40

supply two values first is number of

play13:42

mangoes second is rate

play13:44

and soon after supplying these two

play13:46

values will

play13:47

get a value which will be the value of

play13:50

bill okay so this is our problem number

play13:53

one problem number three now we are just

play13:57

okay for for some time we are shifting

play13:59

from bogilal

play14:00

okay we are taking one more very simple

play14:03

flowchart draw flowchart to find

play14:05

average of three numbers ok

play14:09

so now this has to be a generalized

play14:11

program which should be able to find

play14:13

average of any three numbers okay

play14:16

now the question arises who will be

play14:18

supplying those numbers

play14:20

the user will supply three numbers okay

play14:23

for which he wants to find average so

play14:25

since the user has to supply three

play14:27

numbers so our flow chart will be like

play14:29

this will write

play14:30

start

play14:37

and after this because numbers have to

play14:39

be supplied by the user so i will have

play14:41

to input those numbers

play14:43

input means numbers will be supplied by

play14:46

the

play14:46

user input suppose

play14:50

ok i am just taking three variables n

play14:52

one n two

play14:53

and n three ok so

play14:56

input n one comma n two comma n three so

play14:59

i have taken three variables here

play15:01

n one n two and n three ok

play15:05

see whenever this program will get

play15:06

executed at that time

play15:08

three values will be supplied and first

play15:10

value will be replacing

play15:12

n1 second will be for n2 and third will

play15:14

be for

play15:15

n3 okay so once we have n1

play15:19

n2 and n3 because in our program we are

play15:21

assuming that our three numbers are n1

play15:23

n2 and n3 at the same time we are

play15:26

inputting inputting means whenever this

play15:28

program will get

play15:29

executed user will supply three values

play15:32

for these three

play15:33

n one n two and n three now

play15:36

ah once we know and one in our program

play15:38

we have assumed that numbers are n one

play15:40

and two and

play15:41

n three so what will be the sum

play15:46

sum will be n one comma

play15:49

sorry n one plus n two plus

play15:54

n three this is quite simple

play15:57

some will be n one plus n two plus n

play16:00

three and what will be average

play16:03

ok i am taking a variable avg for

play16:05

average average

play16:07

will be equal to sum divided by

play16:12

3 and once we know the average

play16:16

this will also be a rectangular box

play16:18

because i am doing calculation once we

play16:20

know the average then what will we do

play16:23

we will print average because we were

play16:25

supposed to

play16:26

calculate average so now what are we

play16:28

doing we are displaying it

play16:31

print a v g so whatever is the value of

play16:34

average that will be printed and then we

play16:36

stop

play16:41

ok now again same thing whenever this

play16:46

program will get

play16:47

executed at that time first of all

play16:50

the user has to supply three values

play16:54

user has to supply three values n1 n2

play16:57

and n3 okay based on those three values

play17:01

some will be calculated and after that

play17:03

average will be calculated and then

play17:05

average will be printed ok now i can

play17:08

draw a smaller flowchart also

play17:10

because these two things i can do in a

play17:13

single line also

play17:14

so like let me draw a smaller one start

play17:22

ah input

play17:28

n one comma n two comma

play17:31

n three

play17:37

i can directly calculate average a

play17:40

v g is equal to n one plus

play17:45

n 2 plus n 3

play17:48

this whole divided by

play17:51

3

play17:54

ok since i am calculating so this will

play17:57

be our rectangular box and after that i

play17:59

am writing

play18:03

print average

play18:06

okay print average and then

play18:10

i just a minute

play18:18

and after that i stop

play18:23

ok now what i have done i have done

play18:25

these two things in a single line here

play18:27

ok but

play18:28

i should not write like this i should

play18:30

not write ah

play18:31

some of the students they write like

play18:33

this they write

play18:35

ah average is equal to

play18:38

n 1 plus n 2 plus n 3

play18:42

divided by 3 if they do like this then

play18:46

only

play18:46

n 3 will get divided by 3 okay some of

play18:49

the students are doing it like this also

play18:52

they write

play18:53

average is equal to n 1 plus n 2

play18:57

plus n 3 divided by 3

play19:01

see this is not a computer statement

play19:03

because in computer

play19:05

see whatever language in whatever

play19:07

language you are doing programming

play19:09

you have to write in a single line so

play19:11

here

play19:12

first line second line third line so

play19:15

this is not a valid computer statement

play19:17

ok

play19:17

so your entire expression should be in

play19:20

continuity

play19:21

so what is the right way of doing it i

play19:23

have to write like this

play19:24

average is equal to n 1 plus n 2

play19:28

plus n 3 this whole

play19:31

divided by 3 okay so these 2 are

play19:35

wrong ok fine

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
FlowchartsProgrammingProcess DiagramSequence InstructionsDecision MakingInput OutputCalculationsAssignment BoxConnectorsLoops
Benötigen Sie eine Zusammenfassung auf Englisch?