EXPT 3

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

EXPT NO: 3 DATE:

FLOWCHART

The first design of flowchart goes back to 1945 which was designed by John Von
Neumann. A flowchart uses different symbols to design a solution to a problem. It is
another commonly used programming tool. By looking at a flowchart one can
understand the operations and sequence of operations performed in a system.
Flowchart is often considered as a blueprint of a design used for solving a specific
problem.

ADVANTAGES OF FLOWCHART:

 Flowchart is an excellent way of communicating the logic of a program.


 Easy and efficient to analyze a problem using flowchart.
 During program development cycle, the flowchart plays the role of a blueprint,
which makes program development process easier.
 After successful development of a program, it needs continuous timely
maintenance during the course of its operation. The flowchart makes program
or system maintenance easier.
 It is easy to convert the flowchart into any programming language code.
Flowchart is diagrammatic /graphical representation of sequence of steps to solve a
problem. To draw a flowchart following standard symbols are used.

Symbol Name Symbol Function

Used to represent start and end of


Oval
flowchart.

Used for input and output


Parallelogram
operation.

Processing: Used for arithmetic


Rectangle
operations and data manipulations.

Decision making: Used to represent


Diamond an operation in which there are two
alternatives, true and false.

Flow line: Used to represent the


Arrows
flow of logic by connecting symbols.

Page Connector: This symbol is


typically small and is used as a
Circle
connector to show a jump from one
point in the process flow to another.
Off-Page Connector: It shows
continuation of a process flowchart
onto another page.

Predefined Process/Function: Used


to represent a group of statements
performing one processing task.
The language used to write algorithm is simple and similar to day to day life language.
The variable names are used to store the values. The value stored in a variable can
change in the solution steps. In addition some special symbols are used as below.

Assignment Symbol (← or =) is used to assign value to the variable.


E.g. to assign value 5 to the variable HEIGHT, statement is
HEIGHT ← 5
or
HEIGHT = 5
The symbol ‘=’ is used in most of the programming languages as an assignment symbol.
The statement C = A + B means, add the values stored in variable A and variable B and
then assign/store their sum in variable C.
The statement R = R + 1 means, add 1 to the value stored in variable R and then
assign/store the new value in variable R, in other words increase the value of variable
R by 1.
Mathematical Operators:

Operator Operand Operation Description


+ a, b a+b Addition
– a, b a–b Subtraction
* a, b a*b Multiplication
/ a, b a/b Division
Modulo division (to find the
% a, b a%b
remainder of an integer division)

Relational Operators:

Operator Operand Operation Description


== a, b (a==b) Used to check if both operands are equal
!= a, b (a!=b) Used to check if both operands are not equal
Used to check if the first operand is greater
> a, b (a>b)
than the second
Used to check if the first operand is lesser than
< a, b (a<b)
the second
Used to check if the first operand is greater
>= a, b (a>=b)
than or equal to the second
Used to check if the first operand is lesser than
<= a, b (a<=b)
or equal to the second
Logical Operators:

Operator Operand Operation Description

AND: Used to check if both the operands are


&& a, b (a && b)
true
OR: Used to check if at least one of the
|| a, b (a || b)
operands is true

! a !a NOT: Used to check if the operand is false

Selection Control Statements:


Selection control Example Meaning

IF (Condition) Then IF (X > 10) THEN If condition X > 10 is True,


… Y=Y+5 execute the statement
ENDIF ENDIF between THEN and
ENDIF.

IF (Condition) Then IF (X > 10) THEN If condition X > 10 is True,


… Y=Y+5 execute the statement
ELSE ELSE between THEN and ELSE.
…. Y=Y+8 Otherwise execute the
Z=Z+3 statements between ELSE
ENDIF ENDIF and ENDIF.
Loop Control Statements:
Loop Control Example Meaning

while (condition) while (x < 10) Execute the loop as long


{ { as the condition is TRUE
print x
// code block to be
x = x+1
executed }
}
do do Execute the loop until the
{ { condition becomes FALSE
print x
// code block to be
x = x+1
executed } while (x < 10)
} while (condition)

GO TO statement also called unconditional transfer of control statement is used to


transfer control of execution to another step/statement. E.g. the statement GOTO n
will transfer control to step/statement n.

NOTE: We can use keyword INPUT or READ or GET to accept input(s)/value(s) and
keyword PRINT or WRITE or DISPLAY to output the result(s).

You might also like