CP Chapter 1
CP Chapter 1
CP Chapter 1
1
2
Introduction cont..
• A Computer is an electronic device that accepts:
Data
makes logical decisions according to instructions that have been given to it.
• In current world we live in, computers are almost used in all walks of life for different
purposes.
• They have been deployed to solve different real life problems, from the simplest game
• In order to solve a given problem, computers must be given the correct instruction about
• Analog signals are continuous wave forms used to represent things as sound. Audio
• The digit 0 or 1 is called a binary digit, or bit or binary code or binary number
4
Introduction cont..
• Machine language, is a sequence of 0s and 1s that computer reads and interprets.
• The most basic language of a computer, the machine language, provides program
instructions in bits.
• Even though most computers perform the same kinds of operations, the designers of the
computer may have chosen different sets of binary codes to perform the operations.
• Therefore, the machine language of one machine is not necessarily the same as the
• The terms computer programs, software programs, or just programs are the instructions that
programs.
Data – characteristics
Code – action
6
cont..
• A computer program (also known as source code) is often written by professionals known as
• A programming language is an artificial language that can be used to control the behavior
• Programming languages, like natural language (such as English), are defined by syntactic
and semantic rules which describe their structure and meaning respectively.
7
cont..
• The syntax of a language describes the possible combinations of symbols that form a
machines.
Low-level languages
High-level languages
8
Low-level languages
• The most basic language of a computer which provides instruction in bits.
• In the initial years of computer programming, all the instructions were given in binary form.
• Although the computer easily understood these programs, it proved too difficult for a
normal human being to remember all the instructions in the form of 0s and 1s.
• Therefore, computers remained mystery to a common person until other languages such as
assembly language was developed, which were easier to learn and understand.
9
cont..
• Assembly language correspondences symbolic instructions and executable machine codes
and was created to use letters (called mnemonics) to each machine language instructions to
• If binary code 100100 stands for load, 100110 stands for multiplication, and 100010 stands
for store.
• In machine language, you might need the following sequence of instructions to calculate
weekly wages:
10
cont..
100100 010001
100110 010010
100010 010011
• However, no matter how close assembly language is to machine code, computers still
• The instructions first have to be translated into machine language. A program called an
LOAD rate
MULT hours
STOR wages
12
High-level languages
• Programming in assembly language is slow, cumbersome hardware specific. The lack of
• High-level languages are more English-like and, therefore, make it easier for programmers
Some example:
• PASCAL,
• C/C++/C#
• Python,
• Java
• JavaScript/PHP.
14
Programming Paradigm
• The question of which language is best is ,common question among computer
• Every language has its strengths and weaknesses.There is no single standard for
a method to solve a problem using tools and techniques that are available to us following
some approach.
15
Procedural Programming Languages
• Procedural programming specifies a list of operations that the program must complete to
• Each program has a starting state, a list of operations to complete, and an ending point.
• Procedures, also known as functions, subroutines, or methods, are small sections of code
• By splitting the programmatic tasks into small pieces, procedural programming allows a
• It also makes it easier for programmers to understand and maintain program structure.
• Two of the most popular procedural programming languages are FORTRAN and BASIC.
FORTRAN Programming
program addNumbers Output:
real :: a, b, result The total is 27.0
a = 12.0
b = 15.0
result = a + b
print *, 'The total is ', result
end program addNumbers
17
Structured Programming Languages
• Structured programming is a special type of procedural programming.
• It provides additional tools to manage the problems that larger programs were creating.
• Structured programming requires that programmers break program structure into small
• One of the well-known features of structural programming is that it does not allow the use of
• The most popular structured programming languages include C, Ada, and Pascal.
18
Structured Programming Languages
C Programming
#include <stdio.h>
Output:
int main()
27
{
int number1, number2, sum;
number1=12;
number2=15;
// calculate the sum
sum = number1 + number2;
printf("%d", sum);
return 0;
}
19
Object-Oriented Programming Languages
• In object- oriented programs, the designer specifies both the data structures and the types
• This pairing of a piece of data with the operations that can be performed on it is known as an
instructions.
20
cont..
• Objects can store state information and interact with other objects, but generally each
• There are system analysis and design tools, particularly flowchart and structure chart, that
can be used to define the problem in terms of the steps to its solution.
• The programmer uses programming language to communicate the logic of the solution to
the computer.
23
cont..
• Before a program is written, the programmer must clearly understand what data are to be
used, the desired result, and the procedure to be used to produce the result.
• There are three commonly used tools to help to document program logic (the algorithm).
languages, but typically omits details such as subroutines, variables declarations and
system-specific syntax.
• The purpose of using pseudocode is that it may be easier for humans to read than
program.
• As the name suggests, pseudocode generally does not actually obey the syntax rules of any
particular language;
• there is no systematic standard form, although any particular writer will generally borrow
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:
Display an output prompt that explains the answer as the sum Display the result
27
cont..
Example2: Write a pseudocode to find the largest of two numbers by accepting numbers from
user and print 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
28
cont..
Exercise:
Write a pseudocode for a program that obtains one integer number from the user and print out
provides an overview that confirms the solution to the problem without excessive
• Example:
• Write a program that asks the user to enter a temperature reading in centigrade and then
algorithm or a process.
so that it can be used, to translate an algorithm to more than one programming language.
• Example 3: - Write the algorithmic description and draw a flow chart to find the following
sum.
• Sum = 1+2+3+…. + 50
37
Cont..
Example 4: Draw flowchart to find factorial of a positive integer n
38
Cont..
Example 5: Draw flowchart to calculate tax deduction of employees based on the following
requirement:
Requirement: For salary more than 500 birr, tax is 5% of the salary, and for salary less than
500 birr, tax is 3% of the salary.
39
Cont..
Example 6: Draw flowchart to find largest of two numbers.
40
Cont..
Example 7: Draw flowchart to find largest number from three numbers.
41
Cont..
Example 8: Draw a flowchart and algorithm that will determine and print out the sum of all
even and odd integer numbers from 1 to 100.
42
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
• This will include determining whether a business problem or opportunity exists, conducting
a feasibility study to determine if the proposed solution is cost effective, and developing a
project plan.
• A preliminary analysis, determining the nature and scope of the problems to be solved is
carried out.
• The process of developing a large information system can be very costly, and the
investigation stage may require a preliminary study called a feasibility study, which
of the organization.
• Operational Feasibility
• Management support
Requirements analysis
• Requirements analysis is a software engineering task that bridges the gap between system
function, and behavior that can be translated to data, architectural, interface, and component-
level designs.
• End users must be involved in this process to ensure that the new system will function
Designing solution
• Software design is an iterative process through which requirements are translated into a
• That is, the design is represented at a high level of abstraction , a level that can be directly
traced to the specific system objective and more detailed data, functional, and behavioral
requirements.
48
Cont..
Implementation
• The real code is written here. Systems implementation is the construction of the new
• Product implementation can be an exciting phase for the customer, because their idea for
• Testing, mostly known software testing, is an activity performed for evaluating product
complete) exists.
• A primary purpose of testing is to detect software failures so that defects may be discovered
and corrected.
Errors: These are actual coding mistakes made by developers. In addition, there is a
difference in output of software and desired output is considered as an error.
Fault: When error exists fault occurs. A fault, also known as a bug, is a result of an error
which can cause system to fail.
Failure: failure is said to be the inability of the system to perform the desired task.
Failure occurs when fault exists in the system.
51
Cont..
Maintenance
• Maintenance is simply the bulkiest and life long process out of the software development
activities.
• This may not be performed by the development team instead the customer company may
hire additional IT expert to look after this job.
52