Download as pdf or txt
Download as pdf or txt
You are on page 1of 56

FLOWGORITHM LAB

SESSION #F1
Initial window displayed with basic flowchart
This is where the flowchart is defined

2
Output will be shown in a separate window called
the Console

3
Flowgorithm

To insert a symbol into the diagram, click on an


arrow between two symbols…

4
A pop-up menu with options will be displayed
Comments can be added like this:

Flowgorithm

5
Flowgorithm

To edit a symbol, double click it


6
A pop window will allow you to enter text that
explains the "function" of the symbol 7
Type in the content and click OK 8
Content added

9
Flowgorithm

When defining executable symbols often don't


have to specify the "command” like Output 10
Flowgorithm

Flowgorithm will insert the command

11
Flowgorithm

To run, click the Execute to Completion button

12
Flowgorithm

Output displayed in Console in "text balloon"


13
Flowgorithm

To delete a symbol, draw a box around the


symbol(s) with the cursor (symbol will change
color) & press the Delete key
14
15
Flowgorithm

• When you want a user to enter data, you need to "prompt" them
• In an interactive program, prompting means displaying some text
explaining what data the user needs to enter

• On a web page, input fields always have text next to them


explaining what has to be entered
• This text is a prompt
16
17
To read in data into the program, need a variable
to hold the data
18
Flowgorithm
• Variables should be defined at the beginning
of the flowchart after the initial comment

• They are defined in a Declare rectangle

19
Must specify the variable name and data type

20
Read in the number with Input symbol and assign
it to the variable 21
22
Will add an output statement that displays…

23
… the user's number and some text.
Notice how text and variable names are specified

24
When run prompt shown in the console
Enter data in textfield at bottom and click Enter

25
Notice your input on right

26
Addition of two numbers
Swapping of two numbers
Looping using While
Looping using While
Looping using While
Looping using For
Looping using For
Looping using Do
Looping using Do
Factorial of a number
GCD of two numbers
Program- Cost Calculation
Compound Condition
• In Flowgorithm use AND and/or OR in the
diamond shape

39
Sum of digits
Declaring Array
Maximum in an array of
numbers
Including a Function
Function name and parameters
Function name and parameters
Function template
Function call from main when the
function does not return any value
Function call from main

when the function returns a value


Add numbers using
Function
Sum of digits using
function
#F1
Take Home Exercise
Question 1
Number reversal

Accept a number from the user and print its reverse.

52
Question 2
Program - Long Distance Charges
• Long distance charge basics:
• Company charges 10 cents per minute for all calls outside
the customer’s area code that last over 20 minutes

• All other calls are 13 cents per minute

• Create a program to calculate the cost of a phone call


53
• Accept data about one phone call from user
• Customer area code (three chars)
• Customer phone number (eight chars)
• Called area code (three chars)
• Called number (eight chars)
• Call time in minutes (four digits)
• Display:
• All the input data
• Price for the call. 54
Question 3

Find roots of a quadratic equation

55
Question 4

Reverse an array of n numbers, where n is given by the user.

Use a function ‘reverse’ to perform reversal and return the


reversed number.

56

You might also like