PF - 1
PF - 1
Programming Fundamentals
1
2
Course Introduction
Credit Hours: 3 + 1
3 credit hours of class lectures
1 credit hour of Lab (equivalent to 3 hours of Lab work)
3 Course Books
Text Book
C++ How to Program by Deitel & Deitel
Reference Book
C++ Programming: From Problem Analysis to Program Design by: D.S.Malik
Computer Science Illuminated, by Nell Dale, John Lewis, Jones and Bartlett,
Latest Edition
An Introduction to Programming with C++; Diane Zak
Just Enough Programming Logic and Design; Joyce Farrell.
Beginning C++; Ivor Horton
“Turbo C Programming”, Author (s): Robert Lafore.
A First Book of C++: From Here to There, Book by Gary Bronson
4 More books
Processing
5 10
5 + 10 = 15
15
Input
Output
Let us assume we are interested in calculating the sum of 5
and 10. Slide 6 of 40
7 Basic Concepts of Problem Solving
Computer programming is traditionally thought of as problem-solving
process.
A computer program is a solution to a problem
Computer program: The computer program is a set of instructions that tells
the computer hardware what to do and when to do it
There are two parts to develop computer programs, the algorithm and the
syntax
Algorithm: The program’s algorithm is the development of step-by-step,
logical process that the program will follow to reach the desired goal of the
program (the solution)
Syntax : It is the rule of the programming language which dictate proper
statement structure and usage
8 Basic Concepts of Problem Solving
Code the
program
Implement and
Test
maintain
12 The problem-solving process
1. Analyze the problem : Programmer determines
What the program is supposed to do (the purpose of the
program)
What data the program will use ( the programs input);
What the program is supposed to produce (the programs
output);
The process the program will use to transform the data into the
desired output information
Visual tools for this stage can include
Input layout charts that represent how the input data is stored in the
records of a file or how input prompt will appear on the screen
Output layout spacing charts represent what the finished output
report or screen will look like
13 The problem-solving process …
2. Plan the solution : During the planning stage of the
programming development cycle, the programmer utilizes
visual tools such as flow charts, pseudocode and hierarchy
charts to develop the programs algorithm, or solution to the
problem
A flow chart is a graphical representation step-by-step that shows
the flow of control of the program using symbolic diagrams.
Pseudocode is a visual representation of the same step-by-step
logic, but pseudocode is English–like phrases instead of symbols
Once the algorithm has been documented using one or more of
the visual tools, the programmer checks the programs logic by
stepping through the algorithm with realistic test data
At this point the logic errors may be detected and corrected
14 The problem-solving process …
3. Code the program: The program (or source) code is written in
the programming language selected by the programmer
following the rules (or syntax) for that language
Once the source code is written
The program is processed by the language translator program
Any syntax errors are detected by the translator must be
corrected before the machine language (object) can be
generated
When all debugging and syntax errors is complete, a run-time
version of the program can be executed
Language translator: A language translator converts human-
readable source code statements into the machine- readable
object code; depending on the language, the translator will be an
assembler, interpreter, or compiler program
15 The problem-solving process …
4. Test: Testing the program is done using sets of data designed to produce
the expected results
If the program is faulty, the desired results will not be produced
The programmer must then debug the source code and revise the logic in the
planning stages
This stage should require minimal effort
Debug and revise: To debug a program, the programmer finds and corrects
syntax errors in the source code
16 The problem-solving process …
5. Implementation/Deployment and maintain: The final stages of the
programming process is to put the program into production
At this stage, all program documentation must be completed and presented
at the time the program is implemented
The documentation includes all the documents used in the planning stage
(such as input, output charts). The printed source code also becomes a part of
the documentation
In addition, user training manuals are provided as well as any other information
that the end user might require to properly run the program
Maintaining the program includes making appropriate updates to the program
as needed
For instance, if income tax rates change, an update to the tax amounts would be
required for a payroll program
17 Algorithms
18 Al-Khwarizimi Principle
All complex problems can be broken into simpler sub-problems
Solve a complex problem by breaking it down into smaller sub-problems
and then solve them (in a specified order), one at a time
When all the steps are solved, the original problem itself has also been
solved
This process is called Algorithm
19 Divide and Conquer
Hard Problem
Analyze the
problem
Code the
program
Implement and
Test
maintain
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 Algorithms & Pseudocode
A typical programming task can be divided into two phases
Problem Solving phase:
Produce an ordered sequence of steps that describe solution of problem
This sequence of steps is called an algorithm
Implementation phase:
Implement the program in some programming language
24 Sample problem
Input two numbers from the user and print the sum of those two
numbers?
Analyze the problem:
What are the inputs?
Two number (Where to store these)
Need two containers
End
27
Thank you