Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
105 views

Computer Programming: Introduction Programming Tools-Flowcharts

The document provides an introduction to programming tools like flowcharts. It discusses that flowcharts, pseudocode, and hierarchy charts are used to convert algorithms into computer programs. It then focuses on flowcharts, explaining that they are a graphical representation of an algorithm and are helpful in understanding complex problems. The document provides examples of flowchart symbols and guidelines for creating flowcharts. It includes an example flowchart for finding the average of two numbers. Finally, it provides an exercise to create a flowchart for finding the area of a rectangle.

Uploaded by

kurddoski28
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

Computer Programming: Introduction Programming Tools-Flowcharts

The document provides an introduction to programming tools like flowcharts. It discusses that flowcharts, pseudocode, and hierarchy charts are used to convert algorithms into computer programs. It then focuses on flowcharts, explaining that they are a graphical representation of an algorithm and are helpful in understanding complex problems. The document provides examples of flowchart symbols and guidelines for creating flowcharts. It includes an example flowchart for finding the average of two numbers. Finally, it provides an exercise to create a flowchart for finding the area of a rectangle.

Uploaded by

kurddoski28
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Computer

Programming
Lecture 2
Introduction Programming
Tools-Flowcharts

Mr. Abbas kh. Ibrahim


Intro to Programming
Tools
Computer Programming?
• What is programming?
– The process of writing, testing, and maintaining
the source code of computer programs.
– Telling the computer what to do
• Why learn to program?
– Develops logic and problem-solving skills
– Improves attention to detail
– It’s fun!
Computer Programming?
• A program is a set of step-by-step instructions
that directs the computer to do the tasks you
want it to do and produce the results you want.
• A programming language is a set of rules that
provides a way of telling a computer what
operations to perform.
What Can a Program Do?
A program can only instruct a computer to:
• Read Input
• Sequence
• Calculate
• Store data
• Compare and branch
• Iterate or Loop
• Write Output
Again! what is a program?
• How to cook?
• The algorithm.
• Are you a programmer?
Programming Tools

• Flowcharts.
• Pseudo code.
• Hierarchy Chart.
Programming Tools

Three tools are used to convert algorithms into


computer programs:

– Flowchart - Graphically depicts the logical steps to


carry out a task and shows how the steps relate to
each other.

– Pseudocode - Uses English-like phrases with some


terms to outline the program.

– Hierarchy chart - Shows how the different parts of a


program relate to each other.
Introduction to flowcharts

A flowchart is a graphical representation of an


algorithm. These flowcharts play a vital role in the
programming of a problem and are quite helpful in
understanding the logic of complicated and lengthy
problems. Once the flowchart is drawn, it becomes
easy to write the program in any high level
language. Often we see how flowcharts are helpful
in explaining the program to others. Hence, it is
correct to say that a flowchart is a must for the
better documentation of a complex program.
Introduction to flowcharts
Flowcharts are usually drawn using some standard symbols; however,

Start or end of the program

Computational steps or processing function of a program

Input or output operation

Decision making and branching

Connector or joining of two parts of program


Introduction to flowcharts

 The following are some guidelines in flowcharting:


a. In drawing a proper flowchart, all necessary requirements should be listed out in
logical order.
b. The flowchart should be clear, neat and easy to follow. There should not be any
room for ambiguity in understanding the flowchart.
c. The usual direction of the flow of a procedure or system is from left to right or top
to bottom.
d. Only one flow line should come out from a process symbol.

or
Introduction to flowcharts

e. Only one flow line should enter a decision symbol, but two or three flow lines, one
for each possible answer, should leave the decision symbol.

f. Only one flow line is used in conjunction with terminal symbol.


Introduction to flowcharts
h. If the flowchart becomes complex, it is better to use connector symbols to reduce
the number of flow lines. Avoid the intersection of flow lines if you want to make
it more effective and better way of communication.
i. Ensure that the flowchart has a logical start and finish.
j. It is useful to test the validity of the flowchart by passing through it with a simple
test data.

Example of a flowchart:

Problem 1: Write an algorithm and draw the flowchart for finding the average of two
numbers.
Introduction to flowcharts

Algorithm:
Input: two numbers x and y
Output: the average of x and y
Steps:
1. input x
2. input y
3. sum = x + y
4. average = sum /2
5. output average
Introduction to flowcharts
Introduction to flowcharts
Introduction to flowcharts
Introduction to flowcharts
Introduction to flowcharts

An exercise
Problem 2: Write an algorithm for finding the area of a
rectangle.

Hints:
 define the inputs and the outputs
 define the steps
 draw the flowchart
Intro to RAPTOR
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

Further reading: Introduction to Programming with RAPTOR


By Dr. Wayne Brown.
http://raptor.martincarlisle.com/
RAPTOR
RAPTOR – Statements/Symbols

Purpose Symbol Name Description


Start

input Allow the user to enter data. Each data value


INPUT statement is stored in a variable.
End

Start

assignment Change the value of a variable using some


PROCESSING statement type of mathematical calculation.
E nd

S tart
procedure Execute a group of instructions defined in
call the named procedure. In some cases some of
PROCESSING
the procedure arguments (i.e., variables) will
be changed by the procedure's instructions.
End

S tart

output Display (or save to a file) the value of a


OUTPUT statement variable.
End

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.
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.

Good variable names Poor variable names Illegal variable names


tax_rate a (not descriptive) 4sale (does not start with a letter)
sales_tax milesperhour (add underscores) sales tax (includes a space)
distance_in_miles my4to (not descriptive) sales$ (includes invalid character)
mpg
RAPTOR – Operations/Expressions
Operation Description Example
+ addition 3+4 is 7
- subtraction 3-4 is -1
- negation -3 is a negative 3
* multiplication 3*4 is 12
/ division 3/4 is 0.75
^ exponentiation, raise a number to a 3^4 is 3*3*3*3=81
** power 3**4 is 81
rem remainder (what is left over) when 10 rem 3 is 1
mod the right operand divides the left 10 mod 4 is 2
operand
sqrt square root sqrt(4) is 2
log natural logarithm (base e) log(e) is 1
abs absolute value abs(-9) is 9
ceiling rounds up to a whole number ceiling(3.14159) is 4
floor rounds down to a whole number floor(9.82) is 9
sin trig sin(angle_in_radians) sin(pi/6) is 0.5
cos trig cos(angle_in_radians) cos(pi/3) is 0.5
tan trig tan(angle_in_radians) tan(pi/4) is 1.0
cot trig cotangent(angle_in_radians) cot(pi/4) is 1
arcsin trig sin-1(expression), returns radians arcsin(0.5) is pi/6
arcos trig cos-1(expression), returns radians arccos(0.5) is pi/3
arctan trig tan-1(y,x), returns radians arctan(10,3) is 1.2793
arccot trig cot-1(x,y), returns radians arccot(10,3) is 0.29145
random generates a random value in the random * 100 is some value
range [1.0, 0.0) between 0 and 99.9999
Length_of returns the number of characters in a Example ← "Sell now"
string variable Length_of(Example) is 8
For More Information

Further reading: Introduction to Programming with RAPTOR


By Dr. Wayne Brown.
http://raptor.martincarlisle.com/

RAPTOR download page :


http://raptor.martincarlisle.com/

https://www.youtube.com/user/RandallBower

You can also read more about RAPTOR by exploring the same
webpage. It contains some useful articles.
Questions

?
Assignments
Assignments
 Draw a flowchart to generate odd numbers from 5 to 99.

 Draw a flowchart to sum the even numbers from 2 to 100.

 Draw a flowchart to find the sum of 25 numbers entered by


the user from the keyboard.

 Draw a flowchart to find the factorial of a number enter from


the keyboard.

 Draw a flowchart to find the area of the circle.

 Draw a flowchart to find the maximum number among three


numbers entered by the user.

Note: Use RAPTOR to verify your solutions.

You might also like