Basic Programming
Concepts
✓Pseudocode and Flowchart
✓Anatomy of a program
✓Variables
✓Data Types
✓Input/Output
Basic Programming Concept
What is
Pseudocode? ❑ 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.
Basic Programming Concept
How do I write Rules of writing pseudocode
Pseudocode? ✓ For initial word always be capitalize
example of initial word like READ ,
WRITE ,IF , REPEAT etc…
Example :[[
Basic Programming Concept
How do I write Rules of writing pseudocode
Pseudocode? ✓ For initial word always be capitalize
✓ Per line have only one statement.
Example :[[
Basic Programming Concept
How do I write Rules of writing pseudocode
Pseudocode? ✓ For initial word always be capitalize
✓ Per line have only one statement.
✓ Indent to show hierarchy, improve
readability, and show nested
constructs.
Example :[[
Basic Programming Concept
How do I write Rules of writing pseudocode
Pseudocode? ✓ For initial word always be capitalize
✓ Per line have only one statement.
✓ Indent to show hierarchy, improve
readability, and show nested
constructs.
✓ Always end multiline sections using
Example :[[
any of the END keywords
(ENDIF, ENDWHILE, etc.).
Basic Programming Concept
How do I write Rules of writing pseudocode
Pseudocode? ✓ For initial word always be capitalize
✓ Per line have only one statement.
✓ Indent to show hierarchy, improve
readability, and show nested
constructs.
✓ Always end multiline sections using
any of the END keywords
(ENDIF, ENDWHILE, etc.).
✓ Keep your statements programming
language independent.
✓ Keep it simple, concise, and readable.
Basic Programming Concept
What is the pseudocode BEGIN
set variable for three number (a,b,c)
to determine the largest set variable for temp (d)
number among of the INPUT first number (a)
INPUT second number (b)
three number/integers INPUT third number (c)
inputted? IF a<b
true:
d=b
false:
d=a
END IF
IF d<c
true:
d=c
false:
d=d
END IF
PRINT "largest number is" d
END
Basic Programming Concept
We will often have to represent an expression when
Pseudocode there are computation like add , minus ,multiplication
etc... Below are maybe useful to represent
mathematical operation .
Calculation
Symbols ✓ Grouping ()
✓ Exponent ** or ^
✓ Multiply *
✓ Divide /
✓ add +
✓ subtract -
Basic Programming Concept
When we have to make comparison between action
Pseudocode like a “less than “ b , to make simple pseudocode we
can write a < b. Below is universally accepted symbol
to represent comparison phrases.
Selections
> (greater than)
< (less than)
>= (greater than or equal to)
<= (less than or
= (equal to)
<> (not equal to)
Basic Programming Concept
AND : if one of the two comparation is FALSE
Pseudocode then the whole condition is FALSE.
IF day = “Saturday” AND weather = “sunny”
WRITE “Let’s go to the beach!”
Logical ENDIF
Operators OR : if one of the two comparation is TRUE then
the whole condition is TRUE.
IF month = “June” OR month = “July” OR month = “August”
WRITE “Yahoo! Summer vacation!”
ENDIF
NOT : reverse outcomes of the expression.
IF a NOT even number
WRITE “the number is odd number”
ENDIF
Basic Programming Concept
Example :
Difference between algorithm and pseudocode
What is
Flowchart? ✓is a type of diagram that
represents a workflow or process.
✓can also be defined as a
diagrammatic representation of an
algorithm, a step-by-step
approach to solving a task.
✓shows the steps as boxes of
various kinds, and their order by
connecting the boxes with arrows.
Basic Programming Concept Wikipedia
Flowchart Oval : begin, end or start, stop
symbols
Parallelogram : denotes either an
input operation (read , input ) or
output operation (display , write)
Diamond : sometimes called “decision
box” , denotes decision (or branch) to
be made . The program should
continue along in one of the two
routes (if –then-else , looping )
Basic Programming Concept
Rectangle : sometimes called
Flowchart “processing box” , denotes process
symbols involve mathematical computation
Arrow : represent the data flow
Circle : sometimes called “on page
connector ” , denotes the
connection of the flowchart with
the page
Pentagon : sometimes called “off
page connector ” , denotes the
connection of the flowchart to
Basic Programming Concept the other page
Flowchart This symbols represent predefined
process like function , procedure
symbols
Hexagon : preparation , this
symbols denotes the initialization
of the program
Cylinder : represent database or
storage of the program
Basic Programming Concept
Example : Draw a flowchart the will display “hello world”.
Begin
display “hello world”
End
Basic Programming Concept
Draw a flowchart the reads number (n) , if n is less than zero
Example : then display the number is negative .
Begin
A
Read/input number
(n)
End
true
n<0
Display “ number is
false negative”
A
Basic Programming Concept
A
Example : Draw a flowchart the input 5 numbers , compute the total of
the 5 numbers , determine and display if the total is an “even
number” or an “odd number”. Hint : total = total + input
number(loop)
Basic Programming Concept
The Basic Anatomy of a Java Application
class HiThere
✓ a reserved {
word , public static void main (String[]args)
means you {
cannot use System.out.println("Hello World!");
}
this word as
}
an identifier
✓ Java is a
case
sensitive
Basic Programming Concept
The Basic Anatomy of a Java Application
class HiThere
✓ This is an
{
identifier, we
public static void main (String[]args)
can make up to
{
identify a
System.out.println("Hello World!");
component of
}
the program
}
✓ Identifiers
must be single
word consist of
AlphaNumeric.
Basic Programming Concept
The Basic Anatomy of a Java Application
Code Blocks
✓ Braces ( ie { } ) class HiThere
delimit an isolated {
block of code. public static void main (String[]args)
✓ All programs have {
several (usually System.out.println("Hello World!");
many) blocks. }
✓ Braces must be }
balanced.
✓ Braces are often
nested.
Basic Programming Concept
The Basic Anatomy of a Java Application
Code Blocks
✓ Braces ( ie { } ) class HiThere
delimit an isolated {
block of code. public static void main (String[]args)
✓ All programs have {
several (usually System.out.println("Hello World!");
many) blocks. }
✓ Braces must be }
balanced.
✓ Braces are often
nested.
Basic Programming Concept
The Basic Anatomy of a Java Application
Methods class HiThere
✓ contain blocks of {
functional code. public static void main (String[]args)
✓ are named by an {
identifier, this is a System.out.println("Hello World!");
method called }
main - applications }
execute their main
✓ method on starting.
✓ the syntax of main
must be exactly as
shown.
Basic Programming Concept
The Basic Anatomy of a Java Application
Statements
class HiThere
✓ The program contains a single
{
statement (statements are public static void main (String[]args)
terminated by a semi-colon). {
println System.out.println("Hello World!");
✓ This statement calls a library }
method called System.out.println. }
✓ Methods may be provided with an
argument (data), which is
contained in brackets.
The argument of println is a string
✓ A string is a sequence of
characters.
✓ Java strings are delimited by
double quotes.
Basic Programming Concept
The Basic Anatomy of a Java Application
Style /*
Line breaks and indents are A Simple Java Program
ignored by the compiler, but help */
greatly with readability. class HiThere
Comments {
▪ Comments are ignored by the public static void main (String[]args)
compiler. // This is the main method
▪ Comments may be delimited {
by /* */ System.out.println("Hello World!");
▪ Comments may be delimited }
by // to the end of the line. }
Basic Programming Concept
To be continue . . . . . .