You are on page 1of 9

Pseudocode-

A notation resembling a simplified programming language, used in program


design. Pseudocode is a simple way of writing programming code in
English. Pseudocode is not actual programming language. It uses short
phrases to write code for programs before you actually create it in a specific
language. Once you know what the program is about and how it will
function, then you can use pseudocode to create statements to achieve the
required results for your program. It uses the structural conventions of a
normal programming language, but is intended for human reading rather
than machine reading. Pseudocode typically omits details that are essential
for machine understanding of the algorithm, such as variable declarations,
system-specific code and some subroutines. 
 The purpose of using pseudocode is that it is easier for people to
understand than conventional programming language code, and that it is an
efficient and environment-independent description of the key principles of
an algorithm. No standard for pseudocode syntax exists, as a program in
pseudocode is not an executable program. Pseudocode resembles, but
should not be confused with, skeleton programs which can
be compiled without errors.
Example-
Start Program
Enter two numbers, A, B
Add the numbers together
Print Sum
End Program
pseudocode to compute the area of a rectangle:
Get the length, l, and width, w
Compute the area = l*w
Display the area
Now, let's look at an example of pseudocode to compute the perimeter of a
rectangle:
Enter length, l
Enter width, w
Compute Perimeter = 2*l + 2*w
Display Perimeter of a rectangle

Algorithm-
A process or set of rules to be followed in calculations or other problem-
solving operations, especially by a computer. An algorithm is a procedure or
formula for solving a problem, based on conductiong a sequence of
specified actions. A computer program can be viewed as an elaborate
algorithm. As an effective method, an algorithm can be expressed within a
finite amount of space and time[1] and in a well-defined formal language [2] for
calculating a function. An informal definition could be "a set of rules that
precisely defines a sequence of operations." [18] which would include all
computer programs, including programs that do not perform numeric
calculations.
A programming algorithm is a computer procedure that is a lot like a
procedure and tells your computer precisely what steps to take to solve a
problem or reach a goal. The ingredients are called inputs, while
the results are called the outputs.
Example- find the largest

Algorithm LargestNumber
Input: A list of numbers L.
Output: The largest number in the list L.
if L.size = 0 return null
largest ← L[0]
for each item in L, do
if item > largest, then
largest ← item
return largest

An algorithm is a procedure for solving a problem in terms of the actions to


be executed and the order in which those actions are to be executed. An
algorithm is merely the sequence of steps taken to solve a problem. The
steps are normally "sequence," "selection, " "iteration," and a case-type
statement.

In C, "sequence statements" are imperatives. The "selection" is the "if then


else" statement, and the iteration is satisfied by a number of statements,
such as the "while," " do," and the "for," while the case-type statement is
satisfied by the "switch" statement.

Pseudocode is an artificial and informal language that helps programmers


develop algorithms. Pseudocode is a "text-based" detail (algorithmic)
design tool.
The rules of Pseudocode are reasonably straightforward. All statements
showing "dependency" are to be indented. These include while, do, for, if,
switch. Examples below will illustrate this notion.

Examples:

1.. If student's grade is greater than or equal to 60

Print "passed"
else
Print "failed"

2. Set total to zero

Set grade counter to one

While grade counter is less than or equal to ten

Input the next grade


Add the grade into the total

Set the class average to the total divided by ten

Print the class average.

Qualities of a good algorithm


1. Inputs and outputs should be defined precisely.
2. Each steps in algorithm should be clear and unambiguous.
3. Algorithm should be most effective among many different ways to
solve a problem.
4. An algorithm shouldn't have computer code. Instead, the algorithm
should be written in such a way that, it can be used in similar
programming languages.

Write an algorithm to add two numbers entered by user.

Step 1: Start

Step 2: Declare variables num1, num2 and sum.

Step 3: Read values num1 and num2.

Step 4: Add num1 and num2 and assign the result to sum.

sum←num1+num2

Step 5: Display sum

Step 6: Stop

Write an algorithm to find the largest among three different numbers


entered by user.

Step 1: Start

Step 2: Declare variables a,b and c.

Step 3: Read variables a,b and c.


Step 4: If a>b

If a>c

Display a is the largest number.

Else

Display c is the largest number.

Else

If b>c

Display b is the largest number.

Else

Display c is the greatest number.

Step 5: Stop

Flowcharts-
Flowchart is a diagrammatic representation of an algorithm. Flowcharts are
very helpful in writing program and explaining program to others.
A flowchart is a type of diagram that represents an algorithm, workflow or
process. The flowchart shows the steps as boxes of various kinds, and their
order by connecting the boxes with arrows. 

Symbols Used In Flowchart


Different symbols are used for different states in flowchart, For example:
Input/Output and decision making has different symbols. The table below
describes all the symbols that are used in making flowchart

Symbol Purpose Description

Used to indicate the flow of logic by


Flow line
connecting symbols.

Used to represent start and end of


Terminal(Stop/Start)
flowchart.

Input/Output Used for input and output operation.

Used for airthmetic operations and


Processing
data-manipulations.

Used to represent the operation in


Desicion which there are two alternatives, true
and false.

On-page Connector Used to join different flowline

Off-page Connector Used to connect flowchart portion on


Symbol Purpose Description

different page.

Used to represent a group of


Predefined
statements performing one processing
Process/Function
task.

Example 1: Print 1 to 20:


Algorithm:
Step 1: Initialize X as 0,
Step 2: Increment X by 1,
Step 3: Print X,
Step 4: If X is less than 20 then go back to step 2.

Flowchart:

Example 2: Convert Temperature from Fahrenheit (℉) to Celsius (℃)


Algorithm:
Step 1: Read temperature in Fahrenheit,
Step 2: Calculate temperature with formula C=5/9*(F-32),
Step 3: Print C
Flowchart:

You might also like