0% found this document useful (0 votes)
33 views45 pages

C++ ppt @keleme_2013

The document provides an overview of computer programming, including definitions of computers, programming, and programming languages, as well as the basic components of a computer system. It discusses the importance of programming skills, the generations of programming languages, problem-solving approaches, and software development methodologies. Additionally, it covers algorithms, their characteristics, and various ways to express them, alongside practical assignments for students.

Uploaded by

Tesfalegn Yakob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views45 pages

C++ ppt @keleme_2013

The document provides an overview of computer programming, including definitions of computers, programming, and programming languages, as well as the basic components of a computer system. It discusses the importance of programming skills, the generations of programming languages, problem-solving approaches, and software development methodologies. Additionally, it covers algorithms, their characteristics, and various ways to express them, alongside practical assignments for students.

Uploaded by

Tesfalegn Yakob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Computer Programming (ECEG1052)

Chapter one

By:- Mr. Abebe W.

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.

♦A person who writes instruction is computer


programmer.

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?

♦Programming Language Skill -knowing one or more


programming language to talk to the computer and instruct the
machine to perform a task.

♦Problem Solving Skill -skills on how to solve real world


problem and represent the solution in understandable format.

♦Algorithm Development skill -skill of coming up with


sequence of simple and human understandable set of instructions
showing the step of solving the problem.
31-Jan-22 9
Generations of programming language
♦ Programming languages can be: low level and high level
languages.

► Low level languages are machine specific or dependent.

►High level languages like COBOL, BASIC are machine


independent and can run on variety of computers.

31-Jan-22 10
.
1 First Generation (Machine languages, 1940’s )

♦Difficult to write applications


♦This is the computer’s native language
♦Only language the computer really understand
♦Machine depending
♦Difficult to program and to modify
♦They used vacuum tubes for the circuitry.
♦For the purpose of memory, they used magnetic drums.

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…)

♦Are not portable


♦Computers smaller, faster and more energy efficient
♦Advanced from binary to assembly languages(assembler).
♦Highly used in system software development
♦Difficult to learn than higher levels.
♦Knowledge of hard ware is required

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

►True problem situations, either real or predicted, that


require corrective action.

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.

♦Basic logical process that has been developed and


systemized for the various challenges people face.

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

♦The basic task of a top-down approach is to divide the problem


into tasks and then divide tasks into smaller sub-tasks and so on

♦C programming language supports this approach for


developing projects. It is always good idea that decomposing
solution into modules in a hierarchal manner.

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.

♦This approach is easy to see the progress of the project by


developer or customer

♦Testing and debugging is easier and efficient.


♦This approach is good for detecting and correcting time
delays

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.

♦C++ used the bottom-up approach for project


development. It is an alternative approach to the top-
down approach.

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.

♦This approach is good for reusability of code.

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.

♦The programs we design need to be :


►Reliable: the program should always do what it is expected
to do and handle all types of exceptions.

31-Jan-22 24
Cont..
►Maintainable: the program should be in a way that it could
be modified and upgraded when the need arises.

►Portable: it needs to be possible to adept the software


written for one type of computer to another with minimum
modification.

► Efficient: the program should be designed to make optimal


use of time, space and other resources.

31-Jan-22 25
Software Engineering
♦Software engineering is a branch of computer science that
provides techniques to facilitate the development of
computer programs.

♦Is the profession that creates and maintains software


applications by applying technologies.

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

♦Design-Based on the requirements specified in the


analysis phase algorithms are developed at this stage.

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

♦Is the logic of a program


♦A programmer can not write program unless she/he knows
how to solve the problem manually

♦programs must be planned before they are written


♦Is a step-by-step way to solve a 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.

♦Definiteness. Each step of an algorithm must be precisely defined.


♦Effectiveness.
♦ Input specified.
♦Output specified
31-Jan-22 33
An algorithm can be expressed in many ways
♦Narrative
♦Structured English
♦Pseudo Code
♦Flow chart
♦Program

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.

Solution First you must get two numbers to be added , then


call the first number one & the second number two then
add number one on number two or the vice versa & then
print out the result.
31-Jan-22 35
2. Structured English
Get two numbers
Add them up
Print the output

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

Read num 1, num2


Sum num1, num 2
Print Sum

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

You might also like