Lecture 5 Fundamentals of Programming
Lecture 5 Fundamentals of Programming
Programming
Programming – Why?
Computers are used for many different purposes in many
different situations.
◦ How long will it take me to get home if I drive x miles per hour?
What will be the input data required? (if any). This is the problem formulation
Steps in computer programming
2. Write the steps of computation that are necessary to arrive at the solution.
This is setting up the algorithm.
2. Assembly Language
-The latest of the versions is the ASCII-16 coding scheme which uses 16
bits. ASCII is the most widely coding scheme used in microcomputers.
Internal Data Representation
-Unicode or ASCII-16 which is a version of ASCII uses 2 bytes (16
bits) to represent a character, instead of 1 byte (8 bits) and therefore
can handle 65,536 characters rather than just 256
Table 1.1 shows the codes for the uppercase alphabetic letters and
numerical digits, 0 to 9. (See Table 1.1)
Table 1.1
Advantages of Machine Language
1. Machine language makes fast and efficient use of the computer.
hence program developed for one system does not execute on other system.
2. Complex Language for Programming : Since machine language consists only sequence of
0s and 1s, so it is very difficult for programmer to remember and write each instructions
Disadvantages of machine language
3. Error Prone : While programming using machine language everything need to be
expressed in sequence of 0s and 1s which is very tedious task. So errors are frequently
Each family of processors has its own set of instructions for handling
various operations such as getting input from keyboard, displaying
information on screen and performing various other jobs.
https://www.codesansar.com/computer-basics/assembly-language.htm
Advantages of Assembly Language
1. Easy to Understand and Use: Assembly language uses mnemonic
codes which are easy to use and remember.
So, errors which can occur while writing program using assembly
language are less as compared to writing program using machine
language.
Also, assembler provides a way to locate and correct errors.
2. Difficult to Learn :Since assembly language is machine dependent so every type of computer
architecture requires a different assembly language. Programmer need to study and understand
different mnemonic code according to the architecture used.
3. Slow Program Development Time: Developing program in assembly language is slow process
as compared to high level language.
High Level Programming Languages
High-level programming languages are so-called third-generation
languages,
◦ whereas low-level languages can be described as first-generation
(machine code) and
◦ second-generation (assembly language) languages.
.
High Level Languages
High level language is much closer to human language
High level languages are often not dependent of the particular type of
computer used (i.e. more portable) and has its own set of rules called
syntax.
High Level Languages
Its main advantage is that it is easier to read, write and maintain.
The first high level programming languages were designed in the 1950s.
Now there are dozens of such languages available such as BASIC, COBOL,
C, C++, FORTRAN, LISP, PASCAL, prolog, etc.
Compilers and Interpreters
Compiler or interpreter is used to convert high level language to
machine language.
Advantages of High Level Languages
1. Easy to Use and Understand : High level language uses English like
words and they are closer to natural language which makes easy to learn
and understand. Programmer need not to understand detailed computer
architecture for writing programs using high level language.
•If any statement does not conform to or violates the rules or grammar (syntax) of the
language an error message is displayed on the screen.
•Until this error is corrected, program execution cannot proceed and this has the
disadvantage of slowing down the running of the program.
•An interpreter, however, allows errors to be corrected more quickly than a compiler
which prints a (long) list of errors which have to be corrected as a whole rather than
individually before program execution can continue.
Interpreter
•An interpreter, however, allows errors to be corrected more quickly than a compiler
which prints a (long) list of errors which have to be corrected as a whole rather than
individually before program execution can continue.
ASSEMBLER
•As mentioned earlier, This type of software translates and assembles
a program written in assembly code into machine (object) code.
Implementation phase
◦ Implement using a programming language.
Algorithm:
The algorithm is part of the blueprint or plan for the computer program, an algorithm is:
“An effective procedure for solving a class of problems in a finite number of steps.”
• Similarly, computer programs (especially large and complex ones) need to be designed
before they are written.
Can you think of some possible consequences of not designing a program before building
it?
• One of the things considered when designing a computer program is the algorithm
which it will be based on.
Types of Operations
Basic operations eg.
◦ Wet hair
◦ Rinse
◦ Turn on VCR
Conditional operations
◦ If flour is too dry add water
Repeat/looping operations
◦ Repeat step 1 and 2 three times
◦ Repeat steps 2,3,4,…10 until flour becomes soft.
Expressing algorithms
Is natural language good?
◦ For daily life, yes…but for CS is lacks structure and would be hard to follow
◦ Too rich, ambiguous, depends on context
Methods of Flowchart
Methods of Pseudo code
Methods of Decision table
Methods of Data flow Diagram (DFD)
Pseudocode