03-Unit2-CS 1 – PROGRAMMING LOGIC FORMULATION
03-Unit2-CS 1 – PROGRAMMING LOGIC FORMULATION
INTRODUCTION
TO ALGORITHM,
PSEUDOCODE
AND FLOWCHART
In Java, a term used for programming
and algorithm-based fields is referred
to as pseudocode. It allows us to
define the implementation of an
algorithm. In simple words, we can
define it as an algorithm's cooked-up
representation.
In the past decade, the algorithms are
defined with the help of the pseudocode as
they can be interpreted by programmers,
regardless of their programming background
or knowledge. Pseudocode is the false code
or representation of a code that even a
layperson having school-level programming
knowledge can understand.
Algorithm is an organized, logical
sequence of actions or attitudes
towards a particular problem. In order
to solve a problem, a programmer
implements an algorithm. The
algorithm is expressed using natural
verbal but few technical observations.
It is written in the form of annotations
and informational text that is written in
plain English only. Just like
programming languages, it doesn't
have any syntax, so it cannot be
compiled or interpreted by the
compiler.
Advantages of Pseudocode
In order to improve the readability of any approach,
pseudocode plays a very important role.
•In between the program and the algorithm,
Pseudocode work as a bridge. It is treated as a
document so that the developer can understand
the program easily.
•Pseudocode focuses on explaining the working on
each line of the program. Due to this, it is very
easy for the programmer to construct the code.
Disadvantages of Pseudocode
•The visual representation of the programming code
can be easily understood, and the pseudocode doesn't
provide it.
•There is no well-defined format to write the
pseudocode.
•There are no standards available for pseudocode.
Companies use their own standards to write it.
•If we use pseudocode, we need to maintain one more
document for our code.
A simple example in Java
• Problem: Calculate the sum of two numbers.
• Algorithm (Pseudocode):
1. Start
2. Input num1
3. Input num2
4. Add num1 and num2, store the result in sum
5. Display sum
6. End
HOW TO WRITE ALGORITHM AND
PSEUDOCODE
Writing an algorithm and pseudocode using
the Java programming language involves
breaking down a problem into a step-by-step
sequence of instructions that a computer can
follow. Pseudocode is a way to express this
algorithm in a human-readable and high-
level format before actually writing the Java
code.
Let's go through the process with a simple example:
Finding the sum of two numbers.