Raptor Programa Guia De Uso
Enviado por miriam2203 • 8 de Abril de 2014 • 3.364 Palabras (14 Páginas) • 411 Visitas
Introduction to Programming with RAPTOR
By Dr. Wayne Brown
What is RAPTOR?
RAPTOR is a visual programming development environment based on flowcharts. A flowchart is a collection of connected graphic symbols, where each symbol represents a specific type of instruction to be executed. The connections between symbols determine the order in which instructions are executed. These ideas will become clearer as you use RAPTOR to solve problems.
We use RAPTOR in CS110 for several reasons.
• The RAPTOR development environment minimizes the amount of syntax you must learn to write correct program instructions.
• The RAPTOR development environment is visual. RAPTOR programs are diagrams (directed graphs) that can be executed one symbol at a time. This will help you follow the flow of instruction execution in RAPTOR programs.
• RAPTOR is designed for ease of use. (You might have to take our word for this, but other programming development environments are extremely complex.)
• RAPTOR error messages are designed to be more readily understandable by beginning programmers.
• Our goal is to teach you how to design and execute algorithms. These objectives do not require a heavy-weight commercial programming language such as C++ or Java.
RAPTOR Program Structure
A RAPTOR program is a set of connected symbols that represent actions to be performed. The arrows that connect the symbols determine the order in which the actions are performed. When executing a RAPTOR program, you begin at the Start symbol and follow the arrows to execute the program. A RAPTOR program stops executing when the End symbol is reached. The smallest RAPTOR program (which does nothing) is depicted at the right. By placing additional RAPTOR statements between the Start and End symbols you can create meaningful RAPTOR programs.
Introduction to RAPTOR Statements/Symbols
RAPTOR has six (6) basic symbols, where each symbol represents a unique type of instruction. The basic symbols are shown at the right. The top four statement types, Assignment, Call, Input, and Output, are explained in this reading, The bottom two types, Selection and Loops, will be explained in a future reading.
The typical computer program has three basic components:
• INPUT – get the data values that are needed to accomplish the task.
• PROCESSING – manipulate the data values to accomplish the task.
• OUTPUT – display (or save) the values which provide a solution to the task.
These three components have a direct correlation to RAPTOR instructions as shown in the following table.
Purpose Symbol Name Description
INPUT input statement Allow the user to enter data. Each data value is stored in a variable.
PROCESSING assignment statement Change the value of a variable using some type of mathematical calculation.
PROCESSING procedure call Execute a group of instructions defined in the named procedure. In some cases some of the procedure arguments (i.e., variables) will be changed by the procedure's instructions.
OUTPUT output statement Display (or save to a file) the value of a variable.
The common thread among these four instructions is that they all do something to variables! To understand how to develop algorithms into working computer programs, you must understand the concept of a variable. Please study the next section carefully!
RAPTOR Variables
Variables are computer memory locations that hold a data value. At any given time a variable can only hold a single value. However, the value of a variable can vary (change) as a program executes. That's why we call them "variables"! As an example, study the following table that traces the value of a variable called X.
Description Value of X Program
• When the program begins, no variables exist. In RAPTOR, variables are automatically created when they are first used in a statement.
Undefined
• The first assignment statement, X←32, assigns the data value 32 to the variable X. 32
• The next assignment statement, X←X+1, retrieves the current value of X, 32, adds 1 to it, and puts the result, 33, in the variable X. 33
• The next assignment statement, X←X*2, retrieves the current value of X, 33, multiplies it by 2, and puts the result, 66, in the variable X. 66
During the execution of the previous example program, the variable X stored three distinct values. Please note that the order of statements in a program is very important. If you re-ordered these three assignment statements, the values stored into X would be different.
A variable can have its value set (or changed) in one of three ways:
• By the value entered from an input statement.
• By the value calculated from an equation in an assignment statement.
• By a return value from a procedure call (more on this later).
It is variables, and their changing data values, that enable a program to act differently every time it is executed.
All variables should be given meaningful and descriptive names by the programmer. Variable names should relate to the purpose the variable serves in your program. A variable name must start with a letter and can contain only letters, numerical digits, and underscores (but no spaces or other special characters). If a variable name contains multiple "words," the name is more "readable" if each word is separated by an underscore character. The table below shows some examples of good, poor, and illegal variable names.
Good variable names Poor variable names Illegal variable names
tax_rate
sales_tax
distance_in_miles
mpg a (not descriptive)
milesperhour (add underscores)
my4to (not descriptive)
4sale (does not start with a letter)
sales tax (includes a space)
sales$ (includes invalid character)
IMPORTANT: If you give each value in a program a meaningful, descriptive variable name, it will help you think more clearly about the problem you are solving and it will help you find errors in your program.
One way of understanding the purpose of variables is to think of them as a means to communicate information between one part of a program and another. By using the same variable name in different parts of your program you are using the value that is stored at that location in different parts of your program. Think of the variable as a place holder or storage area for values between each use in your program computations.
When a RAPTOR
...