0% found this document useful (0 votes)
31 views34 pages

Ch1 C++

Ccpp

Uploaded by

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

Ch1 C++

Ccpp

Uploaded by

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

WALLAGA UNIVERSITY

COLLEGE OF ENGINEERING AND TECHNOLOGY

DEPARTMENT OF INFORMATION SCIENCE


Fundamentals of Programming I Tutorial

By: Diriba Girma

Feb, 2023
Introduction to Programming

2
Introduction
 Definition of Computers
 Is an electronic device that accepts data, performs
computations, and makes logical decisions according to
instructions that have been given to it; then produces
meaningful information in a form that is useful to the user
 Characteristics of Computers
 Speed
 Accuracy
 Storage Capacity
 Versatility
 Diligence

3
Introduction…
 Computer System
 Hardware
 Input devices
 E.g mouse, keyboard, joystick, etc
 CPU
 Registers
 ALU
 Control Unit
 Storage devices
 Primary memory – volatile
 Secondary memory
 Output devices
 E.g Moniter, printer, plotter, speaker, etc

4
Introduction…
 Software
 System Software
 Operating System
 Programming Languages
 Utility Software
 Application Software
 E.g MS Word, MS Excel, MS Access, Windows Media Player, Adobe
Photoshop, etc.

 Computer programs, software programs, or just programs


– are the instructions that tells the computer what to do.
 Programming: is the art and science of designing and writing
programs.

5
What is programming?
 Programming is a skill that can be acquired by a computer
professional that gives him/her the knowledge of making
the computer to perform the required operation or task.
 Is the process of writing, testing, debugging/troubeshooting
and maintaining the source code of computer programs.

6
Con’t
 For someone to be a programmer, in addition to basic skills
in computer, needs to have the following major skills:
 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 of coming up with
sequence of simple and human understandable set of
instructions showing the step of solving the problem.

7
Cont
Computer programs (also known as source code) is
often written by professionals known as Computer
Programmers (simply programmers).
A programming language
 Is an artificial language that can be used to control the
behavior of a machine, particularly a computer.
 is a set of keywords and syntax rules that are used to “tell" the
computer what you want it to do..
 Require a greater degree of precision and completeness.

8
Types of Programming Language
 Divided into low level and high level
 Low level languages
 Machine language:-
 A set of instructions coded so that the computer can use it directly
without further translation
 Assembly language
 Symbolic instructions was created
 Use letters (called mnemonics) to each machine language
instructions.
 E.g. ADD A, B – adds two numbers in memory location A and B
 Assembly language is nothing more than a symbolic
representation of machine code.
 The assembly language must be translated to machine code by a
separate program called assembler.

9
Types of Programming Language (cnt’d)

 High level languages


 Permitted a programmer to ignore many low-level details of the
computer's hardware.
 Are more English-like and, therefore, make it easier for
programmers to "think" in the programming language.
 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.
 E.g. PASCAL, C, C++, Java, FORTRAN , etc
 Every language has its strengths and weaknesses.

10
Programming Paradigm
 A programming paradigm provides the programmer's
view of code execution.
 Procedural Programming Languages
 Procedural programming specifies a list of operations
that the program must complete to reach the desired
state. Each program has a starting state, a list of
operations to complete, and an ending point.

11
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 pieces of code that
are easily understood.
 The most popular structured programming languages
include C, Ada, and Pascal.
 Modeling process and data separately
 Suitable for small sized software

12
Object-Oriented Programming Languages

 Object-oriented programming is one the newest and most


powerful paradigms. In object oriented programs, the
designer specifies both the data structures and the types
of operations that can be applied to those data structures.
 This pairing of a piece of data with the operations that
can be performed on it is known as an object.
 Things are made up of objects
 Objects are identified having data and function

13
Software 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. The phases
of SDLC are discussed below briefly.
 Feasibility study
 The first step is to identify a need for the new system. 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.
 This process may involve end users who come up with an idea
for improving their work

14
 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 includes e.g. the following components:
 i) Organizational Feasibility
 How well the proposed system supports the strategic objectives of the
organization.
 ii) Economic Feasibility
 Cost savings
 Increased revenue
 Decreased investment
 Increased profits

 iii) Technical Feasibility


 Hardware, software, and network capability, reliability and availability
 iv) Operational Feasibility
 End user acceptance
 Management support
 Customer, supplier, and government requirements

15
Requirement Analysis
 Requirements analysis is the process of analyzing the
information needs of the end users, the organizational
environment, and any system presently being used, developing
the functional requirements of a system that can meet the needs
of the users.
 Designing Solution
 After the requirements have been determined, the necessary
specifications for the hardware, software, people, and data
resources, and the information products that will satisfy the
functional requirements of the proposed system can be
determined.
 The design will serve as a blueprint for the system and helps
detect problems before these errors or problems are built into the
final system.

16
Testing Designed Solution
 A smaller test system is sometimes a good idea in
order to get a “proof-of-concept” validation prior to
committing funds for large scale fielding of a system
without knowing if it really works as intended by the
user.
Implementation (Coding)
 Systems implementation is the construction of the
new system and its delivery into production or day-to-
day operation. The key to understanding the
implementation phase is to realize that there is a lot
more to be done than programming.

17
 Unit Testing
Normally programs are written as a series of individual modules, these
subjects to separate and detailed test.
 Integration and System testing
It brings all the pieces together into a special testing environment, then
checks for errors, bugs and interoperability. The system is tested to ensure
that interfaces between modules work (integration testing), the system
works on the intended platform and with the expected volume of data
(volume testing) and that the system does what the user requires
(acceptance/beta testing).
 Maintenance
What happens during the rest of the software's life: changes, correction,
additions; moves to a different computing platform and more? This, the
least glamorous and perhaps most important step of all, goes on seemingly
forever.

18
Problem Solving Techniques
 Computer solves varieties of problems that can be
expressed in a finite number of steps leading to a
precisely defined goal by writing different programs.
 In computer programming two facts are given more
weight:
 The first part focuses on defining the problem and logical
procedures to follow in solving it.
 The second introduces the means by which programmers
communicate those procedures to the computer system so
that it can be executed.

19
Design and Implementation of Algorithms
An algorithm is a finite set of instruction that specify a sequence of operations to be
carried out in order to solve a specific problem of class of problems.

A solution to a problem is called an algorithm; it describes the sequence of steps to be


performed for the problem to be solved.

It is just a tool for solving a problem

Shortly an algorithm means:


 A finite set of an instruction that specifies a sequence of operation to be
carried out in order to solve a specific problem.
 An unambiguous procedure specifying a finite number of steps to be taken.
 It is precise and independent of specific programming languages.

20
Methods of Specifying Algorithm
 Finiteness: - there is an exact number of steps to be taken and has
an end.
 Correctness: - it must be correct and must solve the problem for
which it is designed.
 Absence of Ambiguity: - means that every instruction is precisely
described and clearly specified. . Every step in an algorithm must be
clear as to what it is supposed to do and how many times it is
expected to be executed.
 Sequence of Execution - instructions are performed from top to
bottom.
 Input and Output - defined the unknowns of the problem is specified
and with the expected outcome.
 Effectiveness - the solution prescribed is guaranteed to give a correct
answer and that the specified process is faithfully carried out.
 Scope Definition - applies to a specific problem or class of problem.

21
Con’t
 Algorithms are usually represented in pseudo code or
by a flow chart
 Pseudo code: is English like language for representing the
solution to a problem. It s written in something similar to
computer language but in a more understandable format.
 Pseudo code is independent of any programming language.
 Pseudo code (or a flow chart) is the first step in the process of
planning the solution to a problem (also called developing an
algorithm).
 Flow chart: is a graphical way of representing the solution to
a problem.

22
Steps in Problem Solving
 First produce a general algorithm (one can use
pseudocode)
 Refine the algorithm successively to get step by step
detailed algorithm that is very close to a computer
language.
 Pseudocode is an artificial and informal language
that helps programmers develop algorithms.
Pseudocode is very similar to everyday English.

23
Pseudocode & Algorithm
 Example 1: Write an algorithm & the pseudocode to
determine a student’s final grade and indicate whether it is
passing or failing. The final grade is calculated as the
average of four marks.
Pseudocode:
 Input a set of 4 marks
 Calculate their average by summing and dividing by 4
 if average is below 50
Print “FAIL”
else
Print “PASS”

24
Pseudocode & Algorithm

Detailed Algorithm
 Step 1: Input M1,M2,M3,M4
Step 2: GRADE  (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif

25
Example: 2

 Algorithm to add two numbers.


 Step 1: start
 Step 2: Read two numbers n1 and n2.
 Step 3: sumn1+n2
 Step 4: print sum
 Step 5: stop

26
Example-3

 Algorithm to find largest number from three numbers.


 Step 1: start
 Step 2: Read three numbers x1,x2 and x3
 Step 3: if x1 > x2 and x1 > x3 then
 largex1
 Else
 If x2 > x1 and x2 > x3 then
 largex2
 else
 largex3
 Step 4: display large
 Step 5: stop

27
Flow chart
 A flow chart consists of an ordered set of standard
symbols (mostly, geometrical shapes) which represent
operations, data flow or equipment.
 There are two types of flow charts.
 System flow-charts the overall logic of data processing
system.
 A program flow chart shows the operations and logical
decisions of a computer program.
 The standard flowchart symbols and their meaning is
given below.

28
Con’t

29
Flow charting Guidelines
 The flow chart should flow from top to bottom
 If the chart becomes complex, utilize connecting
blocks
 Avoid intersecting flow lines
 Use meaningful description in the symbol

30
Example: 1
START

Step 1: Input M1,M2,M3,M4


Input
Step 2: GRADE  (M1+M2+M3+M4)/4
M1,M2,M3,M4
Step 3: if (GRADE <50) then
Print “FAIL”
GRADE(M1+M2+M3+M4)/4
else
Print “PASS”
N  Y endif
IS
GRADE<50

PRINT
PRINT
“FAIL”
“PASS”

STOP

31
Example-2

 A flowchart to add two numbers

32
Example-3

 A flow chart to find largest of two numbers

33
 Example 4: flow chart that identify whether a given
number is odd or even.

34

You might also like