Flowgorithm
Data Types
Integer Data Type
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.
Real Data Type
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".
Data Types
String Data Type
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. For example: "CSU, Sacramento",
"computer", and "Year 1947" are all strings.
Boolean Data Type
The Boolean Data Type can store either "true" or "false". These are the basis of decision making in a computer
program.
Data Types Summary
Data Type Notes
Boolean Stores either Boolean true or false
Real Stores a real number
Integer Stores an integer number
String Stores textual data
Identifiers
Any time you define a function or variable, it is given a unique name called an "identifier". To prevent identifiers
from being confused with other items in an expression, they must follow a naming convention. Every programming
language has one and they are fairly consistent from language to language.
In Flowgorithm, identifiers must adhere to the following rules:
● They must start with a letter.
● After the first letter, the identifier can contain additional letters or numbers.
● Spaces are not allowed.
● They cannot be key words or words already defined by Flowgorithm
● Languages such as Visual Basic and C also allow the underscore character "_". Flowgorithm, however, does
not allow it.
● Identifiers are not case-sensitive.
Examples
Valid Identifiers Notes
x Identifiers can be single letter
noun2 Numbers are allowed after the first letter
Operators
The notation used for comparisons logical operators, etc... vary greatly between different programming languages.
Flowgorithm supports the symbols used in mathematics (using Unicode values) as well as the two major families of
programming languages. The "BASIC-family" contains English keywords and operators. The "C-family" (which
includes C, Java, C#) is far more symbolic.
Since mathematics and two major language families are supported, there are redundant operators. Flowgorithm
considers the redundant operates as the same - and any set can be used (or all of them). This allows the student to
use the operators that match the language they plan to to learn later.
Operators
Operator C Family BASIC Family Mathematics
Equality == = =
Inequality != <> ≠
Less Than or Equal <= <= ≤
Greater Than or Equal >= >= ≥
Logical Not ! not ¬
Operators
Operator C Family BASIC Family Mathematics
Logical And && and ∧
Logical Or || or ∨
Multiply * * ×
Divide / / ÷
Modulo % mod
String Concatenation &
Exponent ^
Shapes
Assignment Shape
What it Does
The Assignment shape is used to store the result of a calculation into a variable. This is one of the
most common tasks found in programs.
Example
The example, to the right, declares two variables: area (which stores real numbers) and radius (which
stores integers). It then uses an Assignment Statement to set the 'radius' to 7. Finally, it computes
the area of a circle and stores the result in 'area'.
Shapes
Declare Shape
What it Does
A Declare Statement is used to create variables and arrays. These are used to store data
while the program is running. You can declare multiple variables by separating the names
with commas.
Example
The example, to the right, declares two variables: area (which stores real numbers) and
radius (which stores integers). It then uses an Assignment Statement to set the 'radius' to
7. Finally, it computes the area of a circle and stores the result in 'area'.
Shapes
If Shape
What it Does
An If Statement checks a Boolean expression and then executes a true or false branch based
on the result.
Example
The example, to the right, 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!".
Shapes
Input Shape
What it Does
An Input Statement reads a value from the keyboard and stores the result in a variable.
Output Shape
What it Does
An Output Statement evaluates an expression and then displays the result on the
screen.
Activity 3
Using Flowgorithm make a money converter.
PESO -> USD
USD -> EURO
YEN -> PESO