Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Course:

Programming Fundamentals
4.00 Credit Hours, Fall 2023,
Undergraduate Program
Instructor: Attique Ur Rehman

SESSION 1, 2

Week 2
December, 2022

© www.uskt.edu.pk
Problem Solving and
Implementation
• Introduction A programming task can be divided into two
phases:
• Defining a
Problem 1. Problem solving
• Design a • Define : Clearly describe a problem
Solution
• Design its solution: Produce an ordered
• Implementati sequence of steps that describe
on Phase
solution to the problem
2. Implementation phase
Implement the program in some programming
language
write code, compile, link, Test & Debug
Problem Solving and
Implementation
• Introduction

• Defining a
Problem Problem solving
Phase

• Design a
Solution

• Implementati
on Phase Implementation phase
Defining a problem
• Introduction
Break the definition of the problem down
• Defining a
Problem into manageable steps.
• Design a
Solution
1. Input

• Implementati
on Phase
2. Processing

3. Output
Design a solution
• Introduction Algorithm
• A procedure for solving a problem in terms of
• Defining a
Problem 1. The actions to be executed, and
2. The order in which these actions are to be executed
• Design a
Solution • language independent steps

• Implementati
• An Algorithm can be developed with
on Phase
• Pseudo Code
• Flowchart
• Program control: specifying the order in which
statements are to be executed in a computer program
Algorithm
• Introduction Pseudo code
• Defining a • Pseudo code is a method of designing a
Problem
program using English like statement to describe
• Design a
Solution the logic and processing flow.
• Implementati
on Phase

• There are no real rules; organizations follow


their own standards. Conveniently understood
and exchanged between IT professionals.
Exercise 1
• Introduction
Read in the temperature. If the temperature is less
• Defining a
Problem
than 32 indicate below freezing on the screen. Else

• Design a
if the temperature is above freezing then indicate
Solution
the same on the monitor screen.
• Implementati
on Phase Divide the above problem into manageable parts.
1. Input : Read the temperature from keyboard
2. Processing: Test the Temperature below or above freezing
3. Output: Display the result on Screen
Algorithm
• Introduction
Pseudo code
• Course Exercise 1
Introduction
Read the Temp
• Computer
Organization
if (Temp < 32) then
• Software
Categories
Print “BELOW FREEZING”
• Programming
Languages else
• Programming
Tools
Print “ABOVE FREEZING”

• C Language endif
Algorithm
• Introduction Flow Chart
• Defining a
Problem
• Diagrammatic or Graphical representations
• Design a
Solution
of steps for solving the given problem.

• Implementati
on Phase
• Use standard symbols developed by ANSI
(American National Standard Institute)
Algorithm
• Introduction Flow Chart
• Start / End
• Defining a
Problem

• Design a • Flow of control


Solution

• Implementati • Processing step


on Phase

• Input/output

• Decision
Algorithm
Start
• Introduction Flow Chart
• Defining a
Problem Read
Temp
• Design a
Solution
Temp
<32 No
• Implementati Yes
on Phase
Print Print
“Below “Above
Freezing” Freezing”

End
Exercise 2
• Introduction Determine the sum of first 50 natural numbers.

• Defining a
Problem
Break into steps:

• Design a 1. Input: Nil


Solution
2. Processing: Sum the numbers from 1 to 50
• Implementati 3. Output: Sum
on Phase
Exercise 2
• Introduction Pseudo code

• Defining a
1. Set N=1
Problem
Set Sum = 0
• Design a
Solution 2. Repeat step 3 & 4 while N <= 50
• Implementati
on Phase
3. Sum = Sum + N

4. N = N + 1

5. Print Sum

6. end
Exercise 2
• Introduction Flow Chart Start

• Defining a
Sum=0
Problem
N=1

• Design a
Solution
Y Sum=Sum+N
N≤50
• Implementati N=N+1
on Phase
N

Print Sum

End
Start

Read a,b

Average = (a+b) /2

Print Average

End
Implementation Phase
• Introduction
1. Write a program (source code)
• Defining a
Problem 2. Compile a program (source code to Object
code)
• Design a
Solution
3. Link a Program ( Object code to Executable
code)
• Implementati 4. Test and Debug the Program (rectify the
on Phase
errors in the program)

You might also like