0% found this document useful (0 votes)
45 views46 pages

CSC103 - Programming Fundamentals: Program Development Lecture 3-4

This document summarizes a lecture on program development that included the following key points: 1. It outlined the program development cycle and discussed steps like algorithms, pseudocode, and flowcharts. 2. It provided examples of writing algorithms with steps like working examples, writing down the steps, generalizing, and testing. This included algorithms for calculating x to the power of y and finding the closest point from a set of points. 3. It discussed topics that will be covered in the next lecture, including programming fundamentals.

Uploaded by

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

CSC103 - Programming Fundamentals: Program Development Lecture 3-4

This document summarizes a lecture on program development that included the following key points: 1. It outlined the program development cycle and discussed steps like algorithms, pseudocode, and flowcharts. 2. It provided examples of writing algorithms with steps like working examples, writing down the steps, generalizing, and testing. This included algorithms for calculating x to the power of y and finding the closest point from a set of points. 3. It discussed topics that will be covered in the next lecture, including programming fundamentals.

Uploaded by

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

CSC103 – Programming Fundamentals

Program Development
Lecture 3-4

Instructor
Rizwan Rashid
Lecture Outline
• Program Development Cycle
• Algorithm
• The First Four Steps

2
Programming: Plan First, Then Code

• A good programmer will plan first and write


second
– Breaking down a large programming task into
several smaller tasks
An Overview of Seven Steps
Algorithm
• Set of well-defined logical steps that must be
taken to perform a task
• For example, suppose you have been asked to write a
program to calculate and display the gross pay for an
hourly paid employee.
Here are the steps that you would take:
1. Get the number of hours worked.
2. Get the hourly pay rate.
3. Multiply the number of hours worked by the hourly pay rate.
4. Display the result of the calculation that was performed in Step 3.
Pseudocode
• Pseudocode: fake code
– Informal language that has no syntax rule
– Not meant to be compiled or executed
– Used to create model program
• No need to worry about syntax errors, can focus on program’s
design
• Can be translated directly into actual code in any programming
language
Flowcharts
• Flowchart: diagram that graphically depicts
the steps in a program
– Ovals are terminal symbols
– Parallelograms are input and output symbols
– Rectangles are processing symbols
– Symbols are connected by arrows that represent
the flow of the program
Flow Chart – Raptor Start
Example
"Input Number of Hours Worked"GET hoursWorked

"Get Hourly Rate"GET hourRate

TotalPay ← hoursWorked * hourRate

PUT "Gross Pay of an Employee: "+TotalPay¶

End
First Four Steps

Step 1: Work an Example Yourself


Step 2: Write Down What You Just Did
Step 3: Generalize Your Steps
Step 4: Test Your Algorithm
Example-1
Write a program to compute x raised to the y power
(x y)
Step 1: Work an Example Yourself
x = 3 and y = 4, getting an answer of 3^4 = 81.
Example-1
Step 2: Write Down What You Just Did
Example-1
Step 3: Generalize Your Steps
1-Replacing this occurrence of 3 with x
Example-1
Step 3: Generalize Your Steps
2-Find repetition
Example-1
Step 3: Generalize Your Steps
Example-1
• Step 4: Test Your Algorithm
Example-1
• Step 4: Test Your Algorithm
Example-2
• Problem: Find the closest point out of a set of points to some
other given point
Example-2
Example-2

8.06

Smallest Distance: 8.06


Example-2

8.06
10.82

Smallest Distance: 8.06


Example-2

8.06

7.07

Smallest Distance: 7.07


Example-2

7.07

7.81 Smallest Distance: 7.07


Example-2

7.07

5.66
Smallest Distance: 5.66
Example-2

9.06

5.66
Smallest Distance: 5.66
Example-2

9.22

5.66
Smallest Distance: 5.66
Example-2

5.66
Smallest Distance: 5.66
Example-2
Example-2

5.66
Example-2
Example-2
Example-2
Example-2
Example-2
Example-2
Example-2
Example-2
Example-2
Example-2
Example-2

Call it bestDistance
Example-2

Replace it with S0

Replace it with S1

Replace it with S2
Example-2
Example-2
Pattern of Squares
We have an algorithm that is parameterized over one integer N and
produces a pattern of red and blue squares on a grid that starts all
white. The output of the algorithm for N = 0 to N = 5 is as follows:
Summary

• Program Development Life Cycle

44
Next Lecture

• Programming Fundamentals

45
Exercise

You might also like