C++ ppt @keleme_2013
C++ ppt @keleme_2013
Chapter one
31-Jan-22 1
What Is a Computer?
♦It is a machine that can store and process information.
♦Most computers rely on a binary system that uses two
variables, 0 and 1, to complete tasks such as storing data,
calculating algorithms, and displaying information.
31-Jan-22 2
Cont..
31-Jan-22 3
Basic components of a computer system
♦Five basic components of computer system
►Input Unit.
►Output Unit.
►Storage Unit.
►Central Processing Unit (CPU)
►Arithmetic and Logic Unit (ALU)
►Control Unit.
31-Jan-22 4
Cont..
♦Input unit: Obtains information (data and computer progra
ms) from input devices .
♦Output unit: This takes information that the computer has
processed
♦Memory: It stores computer programs while they are bein
g executed.
♦Central processing unit (CPU): This coordinates and
supervises the operation of the other section.
♦Arithmetic and logic unit (ALU): This unit is responsible
for performing calculations.
♦ Control Unit: Controls the operation of CPU, hence the
computer.
31-Jan-22 5
What is programming?
♦Programming is the process of telling a computer
to do certain things by giving instructions. These
instructions are called programs.
31-Jan-22 6
Why do we need to learn computer programming?
♦To know how to make the computer perform a task.
♦Most users of a computer only use the available applications
on the computer. These applications are produced by
computer programmers.
31-Jan-22 7
What is programming language?
♦ Is a set of instruction used to produce various kinds
of output.
♦Are used to create programs that implement specific
algorithms.
♦is a set of instruction that are compiled together to
perform a specific task by CPU.
♦Used to express algorithms in computer understandable
form.
31-Jan-22 8
What skills do we need to be a programmer?
31-Jan-22 10
.
1 First Generation (Machine languages, 1940’s )
31-Jan-22 11
2.Second Generation (Assembly languages, early 1950’s)
♦Advanced from vacuum tubes to transistors
♦Use symbolic names for acronym and storage locations. (ADD, DELETE,
UPDATE…)
31-Jan-22 12
3Third Generation (High level languages, 1950’s to 1970’s)
♦Use English like instruction. Simple human language &
mathematical notations
♦ Since they have different syntax rules they take considerable
time to learn.
♦ Compilers and interpreters are needed to translate
♦They have (common words) which make them easier to learn
♦ Are procedural(It contains a systematic order of statements,
functions and commands to complete a computational task or
program).
♦It specifies a series of well-structured steps and procedures
within its program.
31-Jan-22 13
4.Fourth Generation (since late 1970’s)
♦Use English like syntax rules, but they are non
procedural (like ordering a meal).
♦Users concentrate on defining the input and output
rather than the program steps required
♦Less control over tasks (you don’t know how each task is
performed)
♦ They need more processing speed.
♦The difference is not that mach form the third
♦Example :Query languages e.g. SQL
31-Jan-22 14
5.Fifth Generation (1990’s)
♦Used in artificial intelligence (AI) and expert systems
♦Used for accessing databases.
♦Resemble more like human speech.
♦Concentrate more on outcome than the process.
♦Example PROLOG, LISP
31-Jan-22 15
Problem solving using computers
♦Problems:
►The gap between the existing and the desired situation
31-Jan-22 16
Problem- Solving
♦Is the process of transforming the description of a problem
into the solution of that problem by using our knowledge.
31-Jan-22 17
There are two approaches of problem solving:
top-down design:
♦In Top-down Model, the focus is on breaking the bigger problem
into smaller one and then repeat the process with each problem
31-Jan-22 18
Top-down Approach
31-Jan-22 19
Advantages of top-down approach
♦In this approach, first, we develop and test most important
module.
31-Jan-22 20
Cont..
Bottom up design:
♦Is the reverse process where the lowest level component are
built first and the system builds up from the bottom until the
whole process is finally completed.
31-Jan-22 21
Cont..
♦In this approach, bottom level modules developed first
(Lower level module developed, tested and debugged).
Then the next module developed, tested and debugged.
This process is continued until all modules have been
completed.
31-Jan-22 22
Cont..
31-Jan-22 23
Basic Program development tips
♦Quality programming is necessary for the economic and
correct solution of problems. This only comes from good
program design.
31-Jan-22 24
Cont..
►Maintainable: the program should be in a way that it could
be modified and upgraded when the need arises.
31-Jan-22 25
Software Engineering
♦Software engineering is a branch of computer science that
provides techniques to facilitate the development of
computer programs.
31-Jan-22 26
Software development method ( Also Software life
cycle )
♦Preliminary Investigation(study)
♦Analysis
♦Design
♦Implementation
♦Testing
♦Maintenance and Documentation
31-Jan-22 27
♦ Preliminary Investigation –is a process of
examining research.
► Defining the problem (examines documents, work
papers, and procedures; observe system operations;
interview key users of the system). Suggesting a
solution (often improving an existing one or building a
new information system)
► Feasibility study (determine whether the solution is
possible)
31-Jan-22 28
► Technical feasibility: whether implementation is
possible with the available or affordable hardware,
software and other technical resources.
► Economic feasibility: whether the benefits of the
proposed solution balance the costs
► Operational feasibility: whether the proposed
solution is needed within the existing managerial and
organizational framework.
31-Jan-22 29
♦Analysis(Requirement gathering) –is a process of
separating into component elements in order to
study the nature
31-Jan-22 30
♦Implementation –is a process of moving of an
idea from concept to reality.
♦Testing –the act of conducting a test.
♦ Maintenance –actions performed to keep some
machine or system in service.
♦Documentation- that explain the operation of a
particular software program.
31-Jan-22 31
Algorithms
♦Is a step by step description of how to arrive at the solution
of the given problem
31-Jan-22 32
Characteristics of good algorithm
♦efficient in time and memory
♦precise and unambiguous and simple
♦Correct
♦Finiteness. An algorithm must always terminate after a finite number
of steps.
31-Jan-22 34
1. Narrative
►can be understood by any user who may not have any
knowledge of computer programming.
Example1:-write an algorithm that used to add two
numbers.
31-Jan-22 36
3. Pseudo code
♦Much similar to real code.
♦We use verbs to write pseudo code.
♦Capitalize important words that show actions
31-Jan-22 37
4. Flow chart
♦Is a pictorial representation of an algorithm
♦It acts like a roadmap for a programmer
31-Jan-22 38
Flow chart symbols
31-Jan-22 39
Cont..
31-Jan-22 40
31-Jan-22 41
5. Program (in C++)
{
int num 1, num 2 , sum=0;
cout << “ enter your first number”;
cin >> num1;
cout << “enter your number 2”;
cin >> num 2;
sum=num1+num2;
cout << sum;
}
31-Jan-22 42
Class work
1. Develop flow chart used to find multiplication of two
numbers.
2. Develop flowchart used to find area of circle.
3. Develop flow chart that used to Find the average of two
numbers given by the user.
4. Develop flow chart that check weather the number is even or
not.
5. Develop a flow chart that used to find the sum of N
numbers
6. Develop a flowchart to display the numbers from 1-100.
31-Jan-22 43
31-Jan-22 44
Individual Assignment one_10%
1. Develop flowchart used to find the maximum number of the
three numbers.
2. Develop a flow chart that used to find the sum of even
numbers.
3. Take an integer from the user and display the factorial of
that number
4. Draw a flowchart for check a given number is prime or not.
5. Draw a flowchart to Print Hello World 10 times.
6. Draw a flowchart to log in to Facebook account.
31-Jan-22 45