Download Overview of Programming - Problem Solving and Structured Programming - Lecture Slides and more Slides Advanced Computer Programming in PDF only on Docsity!
Chapter 1
Overview of
Programming and
Problem Solving
Chapter 1 Topics
- Computer Programming
- Programming Life-Cycle Phases
- Creating an Algorithm
- Machine Language vs. High Level Languages
- Compilation and Execution Processes
- C++ History
- Computer Components
- Computing Profession Ethics
- Problem-Solving Techniques
Programming Life Cycle Phases
• Problem-Solving
• Implementation
• Maintenance
Problem-Solving Phase
- Analyze the problem and specify
what the solution must do
solution(algorithm) to solve the
problem
- Verify that your solution really solves
the problem
One Employee’s Wages
In one week an employee works 52 hours at the hourly pay rate of $24.75. Assume a 40. hour normal work week and an overtime pay rate factor of 1.5.
What are the employee’s wages?
7
40 x $ 24.75 = $990.
12 x 1.5 x $ 24.75= $445.50 ___________
Weekly Wages, in General
If hours are more than 40.
*wages = (40.0 * payRate) + (hours - 40.0) * 1.5 payRate
otherwise
wages = hours * payRate 8
RECALL EXAMPLE
(40 x $ 24.75) +(12 x 1.5 x $ 24.75) = $1435.
Algorithm to Determine an
Employee’s Weekly Wages
**1. Get the employee’s hourly payRate
- Get the hours worked this week
- Calculate this week’s regular wages
- Calculate this week’s overtime wages(if any)
- Add the regular wages to overtime wages(if any)** to determine total wages for the week
What is a
Programming Language?
- A programming language is a
language with strict grammar rules,
symbols, and special words used to
construct a computer program
Implementation Phase: Test
- Testing your program means running(executing) your program on the computer, to see if it produces correct results
- If it does not, then you must find out what is wrong with your program or algorithm and fix it--this is called debugging
Maintenance Phase
- Use and modify the program to meet
changing requirements or correct
errors that show up in using it
- Maintenance begins when your
program is put into use and
accounts for the majority of effort on
most programs
A Tempting Shortcut?
16
GOAL
THINKING CODE
REVISE REVISE
REVISE
DEBUG
DEBUG
DEBUG
TEST
CODE
Memory Organization
- Two circuit states correspond to 0 and 1
- Bit(short for binary digit) refers to a single 0 or 1
- Bit patterns represent both the computer instructions and computer data
- 1 byte = 8 bits
- 1 KB = 1024 bytes
- 1 MB = 1024 x 1024 = 1,048,576 bytes
Machine Language
- Is not portable
- Runs only on a specific type of computer
- Is made up of binary-coded instructions(strings of 0s
and 1s)
- Is the language that can be directly used by the
computer
High Level Languages
- Are portable
- User writes program in language similar to natural
language
- Examples -- FORTRAN, COBOL, Pascal,
Ada, Modula-2, C++, Java
- Most are standardized by ISO/ANSI to provide an
official description of the language