0% found this document useful (0 votes)
59 views

COSC1101 - Programming Fundamentals Lec4

1. Programming tasks can be divided into problem solving and implementation phases. The problem solving phase involves clearly defining the problem and designing a solution in the form of an algorithm or sequence of steps. 2. The implementation phase involves writing code to implement the algorithm, compiling the code into an executable program, linking object code, and testing and debugging the program. 3. Key aspects of problem solving include defining input, processing, and output; identifying users; and assessing feasibility. Design techniques include pseudo code and flowcharts to represent the logic and flow of the algorithm.

Uploaded by

Shoaib Kareem
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

COSC1101 - Programming Fundamentals Lec4

1. Programming tasks can be divided into problem solving and implementation phases. The problem solving phase involves clearly defining the problem and designing a solution in the form of an algorithm or sequence of steps. 2. The implementation phase involves writing code to implement the algorithm, compiling the code into an executable program, linking object code, and testing and debugging the program. 3. Key aspects of problem solving include defining input, processing, and output; identifying users; and assessing feasibility. Design techniques include pseudo code and flowcharts to represent the logic and flow of the algorithm.

Uploaded by

Shoaib Kareem
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Programming Fundamentals

Lecture 4
Problem Solving and Implementation
A programming task can be divided into two phases:

1. Problem solving Define : Clearly describe a problem Design its solution:


Produce an ordered sequence of steps that describe solution to the
problem;

2. Implementation phase: Implement the program in some programming


language write code, compile, link, Test & Debug
Developing a program
Defining a Problem:
Break the definition of the problem down into
manageable steps. Example; input, Processing;
Output
Input ; Read the temperature from keyboard
Processing; Test the Temperature below or above
freezing
Output; Display the result on Screen
Users: Identify the users.
Feasibility & Implementation.
Design the solution
Algorithm A sequence of language independent
steps which may be followed to solve a problem.
An Algorithm can be developed with a:

• Pseudo Code
• Flowchart

Preferably using control Structures.


Algorithm
Pseudo code
• Pseudo code is a method of designing a
program using English like statement to
describe the logic and processing flow.
• There are no real rules; organizations follow
their own standards. Conveniently understood
and exchanged between IT professionals.
Example
Define The Problem
Example-1;
Determine the sum of first 50 natural numbers.

Break into steps


Input – Nil
Processing: Sum the numbers from 1 to 50
Output - Sum
Design the Solution
Example-1; Determine the sum of first 50 natural numbers.

Algorithm; Pseudo Code

1. Set N=1 Set Sum = 0


2. Repeat step 3 & 4 while N <= 50
3. Sum = Sum + N
4. N=N+1
5. Print Sum
6. end
Flow Chart
Implementation Phase
• Write a program (source code)
• Compile a program (source code to Object
code)
• Link a Program ( Object code to Executable
code)
• Test and Debug the Program (rectify the errors
in the program)
Write a code
Create a source code we need an editor

• Line editor --- line by line editing


• Screen editor --- note pad, word pad,
customized editor
• After writing the code we save the code with
file extension e.g .c .cpp
Compile a program
Compiling is the transformation from Source Code
(human readable) into machine code (computer
executable). 
• We need a compiler e.g FORTRAN, PASCAL or C
• It converts user readable code to machine
readable code
• Cannot be executed because different sections
are not mapped together, say not linked together
Link a Program
The object code is combined with required supporting
code to make an executable program. This step
typically involves adding in any libraries that are
required.

• first.obj to first.exe
• Can be executed because different sections are mapped
together.
• Execute the code by simply typing the name of file
first.exe or even first
Test and Debug the program
Debugging is the process of fixing a bug in the
software. ... Testing is the process to find bugs
and errors. Debugging is the process to correct
the bugs found during testing. It is the process
to identify the failure of implemented code.
Program Execution
Two ways:
1. Use command prompt e.g DOS or UNIX
command prompt
2. Use Integrated Development Environment

You might also like