Flowchart Flowchart A flowchart is a graphical or

  • Slides: 22
Download presentation
Flowchart

Flowchart

Flowchart • A flowchart is a graphical or symbolic representation of a process (program).

Flowchart • A flowchart is a graphical or symbolic representation of a process (program). • Each step in the process is represented by a different symbol and contains a short description of the process step. • The flow chart symbols are linked together with arrows showing the process flow direction.

 • When you start a new flowchart, you will see two rounded rectangles

• When you start a new flowchart, you will see two rounded rectangles called "terminals". These symbols represent the beginning and end of your program. • Many flowcharts display the text "start" in the top terminal. Flowgorithm, however, uses the text "Main". • Flowgorithm is the program we will use.

 • Everything in a flowchart is represented by a shape. You will add

• Everything in a flowchart is represented by a shape. You will add your own shapes between the Main and End terminals.

shapes

shapes

example Output “Hello, world” Output (“…” & variable)

example Output “Hello, world” Output (“…” & variable)

*Solve the problem: • We have 2 numbers (A and B) and we want

*Solve the problem: • We have 2 numbers (A and B) and we want to add them and multiply them. – Suggestion: A=10 and B=35 • Now try to solve this equation : x^2 - 9 x + 14 = 0 – Suggestion: use 2 variables (X and Y) and put your own numbers at X, Y to try solve it. (ex. X=4) – Suggestion: X^2 = X*X

Variables types • • Before we use any variable, it must be declared. Variables

Variables types • • Before we use any variable, it must be declared. Variables types: – Integer: The Integer data type is one of the most commonly used types in programming. An integer can store a positive or negative whole number, but can't store fractional values. So, it can store values such as 5, 42, 1947, but can't store numbers such as 3. 2, 4. 5, etc. . . • If a number with a fractional value is stored into a integer, the fractional value will be discarded. Hence, if 3. 2 is stored into an integer, it will only retain 3. – String: The String data type is used to store any textual data. This includes words, letters, or anything else you would send in a text message. In programming, the text is delimited with double quotes. – Real: The Real data type can store any number - both whole numbers and ones with fractional values. In many languages, this is called a "double" after the implementation standard known as "double-precision floating point". – Boolean: The Boolean Data Type can store either "true" or "false". These are the basis of decision making in a computer program. • Example: Integer X X=4 String name Name=“maria” Real Y Y= 1. 69 Boolean flag Flag= True

example Integer X Input X X=X*X Output X

example Integer X Input X X=X*X Output X

* Solve the problem : • We have 2 numbers (A and B) and

* Solve the problem : • We have 2 numbers (A and B) and we want to add them and multiply them. – Suggestion: A=10 and B=35 • Now try to solve this equation : x^2 - 9 x + 14 = 0 – Suggestion: use 2 variables (X and Y) and put your own numbers at X, Y to try solve it. (ex. X=4) – Suggestion: X^2 = X*X

Default shape for if • An If Statement checks a Boolean expression and then

Default shape for if • An If Statement checks a Boolean expression and then executes a true or false branch based on the result.

 • • The following example declares an integer called 'age'. It then reads

• • The following example declares an integer called 'age'. It then reads the age from the keyboard. Finally, an If Statement checks if the age is greater than or equal to 18. Based on this, it either takes the false branch and displays "Sorry, not yet", or takes the true branch and displays "Go vote!".

* Solve the problem: • Make program which reads a STARTING time and a

* Solve the problem: • Make program which reads a STARTING time and a FINISH time. Then it calculates the number of elapsed minutes between those two times. For example: start. Hours = 8 start. Minutes= 30 end. Hours = 10 end. Minutes = 10 minutes = (10 -8)*60 + (10 -30) = 100

solution False else if else True

solution False else if else True

Default shape for/while • For Loops increment a variable through a range of values.

Default shape for/while • For Loops increment a variable through a range of values. • A While Loop evaluates a Boolean expression and, if true, executes statements. It rechecks the expression and loops until it is false.

The following example prints the numbers from 1 to 100 // for

The following example prints the numbers from 1 to 100 // for

The following example prints the numbers from 1 to 100. The assignment statement "n

The following example prints the numbers from 1 to 100. The assignment statement "n = n + 1" increments the variable 'n' each iteration of the loop.

Default shape for do • A Do Loop is similar to a While Loop

Default shape for do • A Do Loop is similar to a While Loop except that the block of statements is executed at least once before the expression is checked.

The following example shows a Do Statement that accepts only valid input. It will

The following example shows a Do Statement that accepts only valid input. It will loop while the 'age' variable is less than 1 or greater than 100

* Solve the problem: • Make a program which adds up a lot of

* Solve the problem: • Make a program which adds up a lot of numbers : 1 + 2 + 3 +. . . + max e. g. max=10 • Do it with while loop and for loop.

For-solution

For-solution

Resources • http: //flowgorithm. org/documentation/tutori al-7. htm • http: //www. breezetree. com/articles/what-isa-flow-chart. htm

Resources • http: //flowgorithm. org/documentation/tutori al-7. htm • http: //www. breezetree. com/articles/what-isa-flow-chart. htm