Binary Code
Letter ASCII Code Binary Letter ASCII Code
Binary
a 097 01100001 A 065
01000001
b 098 01100010 B 066
01000010
Example of machine language for
the text “Hello World” using Binary
Code:
010010000110101 01101100 01101100
01101111 00100000 01010111
01101111 01110010 01101100
01100100
Hello World
01001000 -> ‘H’
0110101 -> ‘e’
01101100 -> ‘l’
01101100 -> ‘l’
01101111 -> ‘o’
00100000 -> ‘ ‘ (space)
01010111 -> ‘W’
01101111 -> ‘o’
01110010 -> ‘r’
01101100 -> ‘l’
01100100 -> ‘d’
Machine Language
The representation of a computer program which is
actually read and understood by the computer.
A program in machine code consists of a sequence of
machine instructions.
Instructions:
Machine instructions are in binary code
Instructions specify operations and memory cells involved
in the operation
Assembly Language
A symbolic representation of the machine language of
a specific processor.
Is converted to machine code by an assembler.
Usually, each line of assembly code produces one
machine instruction (One-to-one correspondence).
Programming in assembly language is slow and error-
prone but is more efficient in terms of hardware
performance.
Mnemonic representation of the instructions and data
Example:
Load Price
Add Tax
Store Cost
High-level language
A programming language which use statements consisting of English-like
keywords such as “for", “print" or “if“, ... etc.
Each statement corresponds to several machine language instructions
(one-to-many correspondence).
Much easier to program than in assembly language.
Data are referenced using descriptive names
Operations can be described using familiar symbols
Example:
Cost = Price + Tax
Procedural Language
Procedural Programming
Languages: Focus on a sequence of
instructions or procedures to solve a problem.
C Language
Fortran
Pascal
BASIC(Beginner's all purpose Symbolic
Instruction Code)
COBOL (Common Business Oriented language)
Object-Oriented Programming Language
Organize programs around "objects" that
combine data and the methods that
operate on that data
C++
Java
Python
C#
Ruby
Swift
Functional Programming
Languages
Emphasize the use of functions and immutable data, promoting a
more mathematical and predictable approach to programming.
Haskell
Erlang
Scala
F#
OCaml
Scripting Language
A scripting language is a programming language
designed for automating tasks and gluing
other software components together .
JavaScript
JSP
ASP
Perl
Ruby
Vbscript
PHP
Logic Programming Languages
Based on formal logic and aim to solve
problems by defining facts and rules,
allowing the computer to deduce
solutions
Prolog
Datalog
Mercury
Markup Languages:
Not strictly programming languages, but
used to structure and present
information. They use tags to define
elements within a document.
HTML
XML
SGML(Standard Generalized Markup
Language)
Domain-Specific Language:
Designed for a particular domain or
application area, offering specialized
features and syntax relevant to that
domain
SQL
HTML/CSS
MATLAB
ALGORITHMS AND FLOWCHARTS
A typical programming task can be divided into
two phases:
Problem solving phase
produce an ordered sequence of steps that describe
solution of problem
this sequence of steps is called an algorithm
Implementation phase
implement the program in some programming
language
Algorithms
Algorithms are used to solve problems
or automate tasks in a systematic and
efficient manner. They are a set of
instructions or rules that guide the
computer or software in performing a
particular task or solving a problem.
There are several reasons why we use
algorithms:
Efficiency: Algorithms can perform tasks quickly and accurately, making
them an essential tool for tasks that require a lot of calculations or data
processing.
Consistency: Algorithms are repeatable and produce consistent results
every time they are executed. This is important when dealing with large
amounts of data or complex processes.
Scalability: Algorithms can be scaled up to handle large datasets or
complex problems, which makes them useful for applications that require
processing large volumes of data.
Automation: Algorithms can automate repetitive tasks, reducing the need
for human intervention and freeing up time for other tasks.
Standardization: Algorithms can be standardized and shared among
different teams or organizations, making it easier for people to collaborate
and share knowledge.
Algorithlm
An algorithm is Finite sequence of steps/instructions to solve a
problem
The word Algorithm means "A set of finite rules or instructions
to be followed in calculations or other problem-solving
operations" Or "A procedure for solving a mathematical problem
in a finite number of steps that frequently involves recursive
operations".
Therefore Algorithm refers to a sequence of finite steps to
solve a particular problem.
Steps in Problem Solving
First produce a general algorithm (one can use
pseudocode)
Refine the algorithm successively to get step by
step detailed algorithm that is very close to a
computer language.
Pseudocode is an artificial and informal language
that helps programmers develop algorithms.
Pseudocode is very similar to everyday English
Pseudocode
A Pseudocode is defined as a step-by-step description of an
algorithm. Pseudocode does not use any programming language in its
representation instead it uses the simple English language text as it
is intended for human understanding rather than machine reading.
Pseudocode is an informal, high-level description of an algorithm or
program, intended for human reading rather than machine
execution. It uses a blend of natural language and programming
constructs, focusing on the logic and flow of a process without
adhering to the strict syntax of any specific programming language.
Pseudocode
Example 1: Write an Pseudocode to determine a student’s final grade
and indicate whether it is passing or failing. The final grade is calculated as
the average of four marks
Pseudocode:
Input a set of 4 marks
Calculate their average by summing and dividing by 4
if average is below 50
Print “FAIL”
else
Print “PASS”
Algorithm
Detailed Algorithm
Step 1: Input M1,M2,M3,M4
Step 2: GRADE (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif
The Flowchart
Flowcharts are graphical representations of data,
algorithms, or processes, providing a visual approach to
understanding code.
Flowcharts illustrate step-by-step solutions to problems,
making them useful for beginner programmers.
Flowcharts help in debugging and troubleshooting
issues.
Flowchart consists of sequentially arranged boxes that
depict the process flow.
Flowchart Symbols
Name Symbol Use in Flowchart
Oval Denotes the beginning or end of the program
Parallelogram Denotes an input operation
Rectangle Denotes a process to be carried out
e.g. addition, subtraction, division etc.
Diamond Denotes a decision (or branch) to be made.
The program should continue along one of
two routes. (e.g. IF/THEN/ELSE)
Hybrid Denotes an output operation
Flow line Denotes the direction of logic flow in the program
Example
START
Step 1: Input M1,M2,M3,M4
Step 2: GRADE
Input
M1,M2,M3,M4
(M1+M2+M3+M4)/4
Step 3: if (GRADE <50) then
Print “FAIL”
GRADE(M1+M2+M3+M4)/4 else
Print “PASS”
N
endif
IS Y
GRADE<50
PRINT PRINT
“FAIL”
“PASS”
STOP
Flowcharts
Flowcharts is a graph used to depict or show a step by step
solution using symbols which represent a task.
The symbols used consist of geometrical shapes that are
connected by flow lines.
It is an alternative to pseudocoding; whereas a pseudocode
description is verbal, a flowchart is graphical in nature.
Flowchart Symbols
Terminal symbol - indicates the beginning and
end points of an algorithm.
Process symbol - shows an instruction other than
input, output or selection.
Input-output symbol - shows an input or an
output
operation.
Disk storage I/O symbol - indicates input from or
output to disk storage.
Printer output symbol - shows hardcopy printer
output.
Flowchart Symbols cont…
Selection symbol - shows a selection process
for two-way selection.
Off-page connector - provides continuation of a
logical path on another page.
On-page connector - provides continuation
of logical path at another point in the same
page.
Flow lines - indicate the logical sequence of
execution steps in the algorithm.
PRINT Hello World in python
print(“Hello World”)
PRINT Hello World in ruby
print ”Hello World”
print hello World in C Language
#include<stdio.h>
void main()
{
printf(“Hello World”);
}
print hello World in C++ Language
#include<iostream.h>
void main()
{
cout<<“Hello World”;
}
print hello World in Java
class Test
{
public static void main(String args[])
{
[Link](“Hello World”);
}