0% found this document useful (0 votes)
4 views19 pages

Introduction to computer Programming

The document outlines the two main phases of programming: problem solving and implementation. It emphasizes the importance of clearly defining a problem, designing a solution using algorithms (in pseudo code or flowcharts), and implementing the solution through coding. Examples are provided to illustrate the process of breaking down problems into manageable steps and developing corresponding algorithms.

Uploaded by

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

Introduction to computer Programming

The document outlines the two main phases of programming: problem solving and implementation. It emphasizes the importance of clearly defining a problem, designing a solution using algorithms (in pseudo code or flowcharts), and implementing the solution through coding. Examples are provided to illustrate the process of breaking down problems into manageable steps and developing corresponding algorithms.

Uploaded by

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

CSC141 Introduction to Computer

Programming
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

Problem solving
Phase

Implementation phase
Defining a Problem:
Break the definition of the problem down into manageable
steps. Example; input, Processing; Output

Input ; Taking raw data from the user


Processing; Applying logic to the data to make it
information.
Output; Display the result on Screen
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.
Defining a Problem:
Break the definition of the problem down into manageable
steps; Input, Processing; Output

Example -1:
Read in the temperature. If the temperature is less than
32 indicate below freezing on the screen. Else if the
temperature is above freezing then indicate the same on
the monitor screen.

Divide the above problem into manageable parts.


Input ; Read the temperature from keyboard
Processing; Test the Temperature below or above
freezing
Output; Display the result on Screen
Algorithm
Pseudo code

• Example -1:
Read the Temperature
if (Temperature < 32) then
Display on screen “BELOW FREEZING”
else
Display on screen “ABOVE FREEZING”
End
Algorithm contd
Pseudo code
Example 2
Write a pseudo code to calculate the weekly
wages of an employee. The pay depends upon
wages per hour and the number of hours
worked.

CSC 141 Introduction to computer


programming
Solution
Divide the above problem into manageable parts.
• Input ; wage per hour, number of hours worked, number of days
worked.
• Processing; (Multiply wage per hour*number of hours worked)*number
of days worked.
Store result in total salary.
• Output; Display total salary on Screen

CSC 141 Introduction to computer


programming
Solution contd
Pseudo code
Read hours worked.
Read wage per hour.
Read days worked.
Calculate salary= (hours worked*wage per
hour)* number of days worked.
Display salary.
End.

CSC 141 Introduction to computer


programming
Algorithm
Flowchart
• Diagrammatic or Graphical representations of steps
for solving the given problem.
• Use standard symbols developed by ANSI (American
National Standard Institute)
Building Blocks of Flowchart
– Start and End Symbols
– Connector
– Arrows (indicate flow of control)

– Processing Steps

– Input/Output

– Decision

CSC 141 Introduction to computer


programming
Defining a Problem:
Break the definition of the problem down into manageable
steps; Input, Processing; Output

Example -1:
Read in the temperature. If the temperature is less than
32 indicate below freezing on the screen. Else if the
temperature is above freezing then indicate the same on
the monitor screen.

Divide the above problem into manageable parts.


Input ; Read the temperature from keyboard
Processing; Test the Temperature below or above
freezing
Output; Display the result on Screen
Example-3:
Determine the largest number of three inputs.

CSC 141 Introduction to computer


programming
Define The Problem
Example-3; Determine the largest number of three inputs..

Break into steps


Input – Three numbers: a,b and c.
Processing – compare the three inputs.
Output – display the largest number.

CSC 141 Introduction to computer


programming
Design the Solution
Example-3; Determine the largest number of three inputs.
(Assume non of them to be equal)

Algorithm; Pseudo Code


Read 1st value in a.
Read 2nd value in b.
Read 3rd value in c.
if (a>b) then
if (a>c) then
display a
else display c
else if (b>c) then
display b
else
display c CSC 141 Introduction to computer
END. programming
Design the Solution
Determine the factorial of an input number.
Algorithm; Flowchart
Start

Read a, b
and c Print b

Yes
Is No Is No
Print c
a>b b>c
Yes
Is No
Print c
a>c
Yes
Print a

End
CSC 141 Introduction to computer
programming

You might also like