Basic Programing I Chapter 1
Basic Programing I Chapter 1
Chapter One
Data Mining Project on
“Prediction of Chronic Kidney Disease Using Data Mining Classification
Introduction to Computer Techniques”
Programming
By
Tewodros Tilahun
Haramaya University
Chapter Outline
Computer Fundamentals
Language Translators
2
Computer Fundamentals
Introduction
Computer is a device that is used to process data according to a set of
Accept data
Process it(performs computations, and)
Makes logical decisions according to instructions that have been given to
it.
In our current world, computers are almost used in all walks of life for different
purposes.
3
Computer Fundamentals Cont.…
They have been deployed to solve different real-life problems, from the
Storage
4
Computer Fundamentals Cont.…
In order to solve a given problem, computers must be given the correct
want it to do, and then the computer executes the program, following each
step to accomplish the end goal.
5
Computer Fundamentals Cont.…
2. Turn to the right and drive until you reach the second square
7
Computer Fundamentals Cont.…
4. Finally, turn to the right and drive for another 50m and you will see the XY
Campus in front
9
Computer Fundamentals Cont.…
10
Computer Fundamentals Cont.…
To understand the computer program see the following sample C++
Program:
int a=3;
int b=5;
int c= a+b;
cout<<“the sum of a+b is”<<c;
The above computer program instructs the computer to add to numbers and
display the result on the computer screen
11
The Evolution of Programing Language
Computer programs?
Sets of instructions that control a computer’s processing of data
The instructions that tell the computer what to do
Computer programs (also known as source code) is often written by
professionals known as Computer Programmers
Computer programming?
It is the process of writing, testing, debugging/troubleshooting, and maintaining
the source code of computer programs
Programming Language
It is a computer language used by computer programmers to communicate with
the computer
It is a collection of instructions written using any language like:
C++
Java
Python to perform a specific task
12
Types of Programing Language
A computer program usually consists of two elements:
Data – Characteristics
Code – action
Source code is written in one of the programming languages
Programing language can be defined by
Syntactic(syntax) – It is used to describe the rules that tell you which statements are
High-Level Language
13
Machine language
It was the first language in the evolution of computer programming language
interprets.
It is machine dependent which means that a particular machine language can be
14
Assembly language
It is a programming language that uses mnemonics/ symbols to write a program.
Example:
ADD A, B
SUB A, B
MUL A, B
Low level: each instruction is minimal
mnemonic.
However, no matter how close assembly language is to machine code,
LOAD rate
MULT hours
STOR wages
16
High-level languages
It is a computer language which can be understood by the user
Are more English-like and, therefore, make it easier for programmers to "think"
in the programming language.
It is not machine dependent which means that it can be used in a different machine
with little modifications.
It require less time to write and easier to debug error.
High-level languages also require translation to machine language before
execution.
Compilers translate the entire source code program before execution.
Interpreters translate source code programs one line at a time.
17
High-level languages
Some examples of high-level languages:
FORTRAN (FORmula TRANslator),
BASIC (Beginner’s All-Purpose Symbolic Instruction Code)
PASCAL,
C/C++/C#
Python
Java
JavaScript/PHP.
18
Language Translators
What is a language translator?
It is a software program that translates a program written in assembly language and
source program and the translated machine code is called object code or object
program.
There are 3 types of language translators:
1. Assembler
2. Interpreter
3. Compiler
19
Types of Language Translators
Assembler
It is a software tool that is used to translate assembly language into machine
language
Compiler
It is a language translator software that is used to translate high-level programs into
machine language
When a compiler converts a source program into a machine program it follows the
message, and you have to correct the error based on the program syntax.
20
Compiler Cont.….
If the program is free from any error then the compiler will convert the entire
source program into machine code at once and finally, the program get
executes.
Example:
Instruction 1;
Instruction 2; Translate Machine code
Execute Output
instruction 3;
instruction 4;
Programing languages like c++ and Java uses a compiler for language
conversion
21
The working principle of compiler
Error Fixed
22
Interpreter
It is another type of translator that converts the high-level program into machine
language.
Unlike compilers interpreters convert the source code to machine code line by
23
Interpreter Cont.….
Interpreter displays an error at a time. The programmer should fix that error to
conversion
The working principle of interpreter
24
Algorithm
An algorithm is the sequence of steps to be performed in order to solve a
problem.
In mathematics, computer science, and related fields an algorithm is a finite
25
Algorithm cont.….
Hence, in order to qualify as an algorithm, a sequence of instructions must
possess the following characteristics:
Every instruction should be precise and unambiguous
26
Quality of Algorithm
The following are the primary factors that are frequently used to judge the quality
of an algorithm:
Time Requirement:
To execute any program computer system may require some amount of time
Memory Requirement
To execute any program computer system may require some amount of space
The algorithm performs better when it requires less amount of memory space.
27
Quality of Algorithm Cont.…
Accuracy of solution:
Several algorithms may provide correct solutions to a given problem some of these
28
Programming Paradigm
A programming paradigm is a fundamental style of programming
Unstructured Programming
consisting only of one large (usually main) program
Disadvantages
Complex
if the same statement sequence is needed at different locations within the program,
30
Programming Paradigm
Procedural programming
• We have a single program, which is divided into small pieces called procedures
Advantage
To re-use the same code at different places in the program without copying it
Example
FORTRAN, ADA
31
Programming Paradigm
Object Oriented Programming
• Object-oriented programming is one the new and most powerful paradigms.
• In object-oriented programs, the designer specifies both the data structures and the
instructions.
• Objects can store state information and interact with other objects, but generally
be used, the desired result, and the procedure to be used to produce the result.
• The procedure, or solution, selected is referred to as an algorithm.
• There are three commonly used tools to help to document program logic (the
33
Pseudocode
• Pseudocode is a compact and informal high-level description of a computer algorithm that
uses the structural conventions of programming languages, but typically omits details
such as subroutines, variables declarations and system-specific syntax.
• It is a simpler version of a programming code in plain English which uses short phrases to
34
Pseudocode
Example1:
Original Program Specification: Write a pseudocode for a program that obtains
two integer numbers from the user and print out the sum of those numbers.
Pseudocode:
Prompt the user to enter the first integer
Display an output prompt that explains the answer as the sum Display the result
35
Pseudocode
Example 2: Write a pseudocode to find the largest of two numbers by accepting
numbers from the user and printing out the largest one.
BEGIN
NUMERIC nNum1,nNum2
DISPLAY "ENTER THE FIRST NUMBER : "
INPUT nNum1
DISPLAY "ENTER THE SECOND NUMBER : "
INPUT nNum2
IF nNum1 > nNum2
DISPLAY nNum1 + " is larger than "+ nNum2
ELSE
DISPLAY nNum2 + " is larger than " + nNum1
END
36
Pseudocode
Exercise:
Write a pseudocode for a program that obtains one integer number from
the user and prints out the square of the number.
37
Structured Charts
38
Flowchart
A flowchart (also spelled flow-chart and flow chart) is a schematic representation
of an algorithm or a process.
The advantage of a flowchart is it doesn’t depend on any particular programming
processes.
The following table shows some of the common symbols.
39
Flowchart
40
Flowchart
Example 1: - Draw flow chart of an algorithm to add two numbers and display
their result.
41
Flowchart
Example 2: Draw flow chart of an algorithm that check whether a number is
negative or not.
42
Flowchart
Example 3: Write the algorithmic description and draw a flow chart to find the
following sum.
• Sum = 1+2+3+…. + 50
43
System Development Life Cycle (SDLC)
The Systems Development Life Cycle (SDLC) is a conceptual model used in
project management that describes the stages involved in a computer system
development project from an initial feasibility study through maintenance of the
completed application.
The phases of SDLC are discussed below briefly:
Testing
Unit Testing
Integrating Testing
System Testing
Maintenance
What happens during the rest of the software's life: changes, correction,
seemingly forever.
Thank y u…!