Introduction to Pseudocode and Flowcharts in Computer Programming

undefined
 
C
HAPTER 1
PSEUDOCODE & FLOWCHARTS
1
st
   Semester 2015
King Saud University 
College Of Applied Studies and Community Services  
CSC 1101
Computer Programming-1
Done By: Asmal Alosaimi
Edited By: Noor Alhareqi & Alaa Altheneyan
Levels of Program Development
Asma Alosaimi
2
1.
Define the problem. 
Human thought
2.
Plan the problem solution. 
 writing the
algorithm
 [pseudo-natural language (English,
Arabic) or drawing the flowchart diagram).
3.
Code the program. 
 High Level
Programming Language (C, C++, Java, …)
4.
Compile the program. 
 Machine Code
5.
Run the program.
6.
Test and debug the program.
From 
Lec1
 we learn that
Asma Alosaimi
3
When planning for a problem solution, algorithms are
used to outline the solution steps using
 
English like statements
, called 
pseudocode
.
or
 A 
flowchart
 , which is a graphical representation of
an algorithm.
Pseudocode
Pseudocode is a detailed description of what a
computer program must do, expressed in an English
like language rather than in a programming
language.
Asma Alosaimi
4
Pseudocode Example
Asma Alosaimi
5
Write a Program to Print the Sum of two integer
Numbers
1.
Start the program
2.
Read the first number and save in  the variable ( N1 )
3.
Read the second number and save in the variable (
N2 )
4.
Sum the both numbers and save the result in the
variable ( Sum )    
 Sum = N1 + N2
5.
Print the variable ( Sum )
6.
End the program
Flowchart
A flowchart is a type of diagram that represents
an algorithm , showing the steps as boxes of various
kinds [ex: 
rectangles, diamonds, ovals
], and their
order by connecting these with arrows.
Asma Alosaimi
6
 
Flowcharts Symbols
7
S
t
a
r
t
R
e
a
d
 
n
1
N
2
 
=
 
5
E
n
d
P
r
i
n
t
 
n
1
N
2
 
=
 
n
1
+
3
n
1
 
>
 
3
Asma Alosaimi
8
Draw a flowchart for a program that calculates
and print the  area and the perimeter of
a rectangle.
Input
Length
width
Processing
Area = length*width
Perimeter = 2*( length + width)
Output
Area
Perimeter
s
t
a
r
t
R
e
a
d
 
L
,
 
W
p
e
r
i
m
e
t
e
r
 
=
 
2
 
(
L
+
W
)
P
r
i
n
t
 
a
r
e
a
E
n
d
a
r
e
a
 
=
 
L
 
*
 
W
 
P
r
i
n
t
 
p
e
r
i
m
e
t
e
r
Solution
Example 2
Draw the flow chart for a program that calculates
the total salary for an employee using this equation:
Total_Sal = Salary +Overtime
Asma Alosaimi
9
Asma Alosaimi
10
s
t
a
r
t
R
e
a
d
 
S
a
l
a
r
y
P
r
i
n
t
 
T
o
t
a
l
_
S
a
l
E
n
d
Total_Sal =
 Salary +Overtime    
Solution
Input
Salary
Overtime
Processing
Total_Sal = Salary +Overtime
Output
Total_Sal
R
e
a
d
 
O
v
e
r
t
i
m
e
Example 3
Asma Alosaimi
11
Draw a flowchart for a program that determine if
the temperature degree is above or below freezing.
Input
Temp.
Processing
Check if Temp is below the 32 
 
below freezing.
Check if Temp is above the 32 
 
above freezing.
Output
Print “below freezing” or “above freezing”
Solution
Asma Alosaimi
12
Example 4
Asma Alosaimi
13
Draw a flowchart for a program that calculates the
Zakat, where the user enter the amount of  money
then the program show the zakat.
Zakat =(2.5/100) * amount.
Zakat is not calculated if the amount is less than 1000
S.R
Solution
Input
amount.
Processing
Check if amount is below 1000 
 
Zakat =0.
Check if amount is above 1000
 
Zakat =(2.5/100) *
amount
Output
Zakat
Asma Alosaimi
14
Solution
Asma Alosaimi
15
Start
End
Amount > 1000
Zakat
 
=0.
Print Zakat
yes
no
Read amount
Zakat
 
=(2.5/100)*amount
Example 5
Asma Alosaimi
16
Draw a flowchart to find the sum of first 50 natural
numbers.
1+2+3+ ….. +50
 
Asma Alosaimi
17
Slide Note
Embed
Share

Explore the concept of pseudocode and flowcharts in computer programming through a detailed explanation of their use in problem-solving, algorithm development, and program design. Learn how to define a problem, plan a solution, code a program, compile and run it, and test/debug the program effectively. Gain insights into creating pseudocode examples and designing flowcharts to represent algorithms visually. Enhance your understanding of key programming concepts with practical applications and illustrations.

  • Pseudocode
  • Flowcharts
  • Problem-solving
  • Algorithm Development
  • Programming Concepts

Uploaded on Sep 29, 2024 | 3 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Noor Alhareqi & Alaa Altheneyan CHAPTER 1 PSEUDOCODE & FLOWCHARTS 1stSemester 2015

  2. Levels of Program Development 2 1. Define the problem. Human thought 2. Plan the problem solution. writing the algorithm [pseudo-natural language (English, Arabic) or drawing the flowchart diagram). 3. Code the program. High Level Programming Language (C, C++, Java, ) 4. Compile the program. Machine Code 5. Run the program. 6. Test and debug the program. Asma Alosaimi

  3. From Lec1 we learn that 3 When planning for a problem solution, algorithms are used to outline the solution steps using English like statements, called pseudocode. or A flowchart , which is a graphical representation of an algorithm. Asma Alosaimi

  4. Pseudocode 4 Pseudocode is a detailed description of what a computer program must do, expressed in an English like language rather than in a programming language. Asma Alosaimi

  5. Pseudocode Example 5 Write a Program to Print the Sum of two integer Numbers Start the program Read the first number and save in the variable ( N1 ) Read the second number and save in the variable ( N2 ) Sum the both numbers and save the result in the variable ( Sum ) Sum = N1 + N2 Print the variable ( Sum ) End the program 1. 2. 3. 4. 5. 6. Asma Alosaimi

  6. Flowchart 6 A flowchart is a type of diagram that represents an algorithm , showing the steps as boxes of various kinds [ex: rectangles, diamonds, ovals], and their order by connecting these with arrows. Asma Alosaimi

  7. Flowcharts Symbols 7 Start Start/End End Print n1 Read n1 Read/Print (input/output) N2 = n1+3 N2 = 5 Arithmetic Operations (process) n1 > 3 Decision , can be used with loops Move from step to step

  8. Solution start 8 Draw a flowchart for a program that calculates and print the area and the perimeter of a rectangle. Input Length width Processing Area = length*width Perimeter = 2*( length + width) Output Area Perimeter Read L, W area = L * W perimeter = 2 (L+W) Print area Print perimeter End Asma Alosaimi

  9. Example 2 9 Draw the flow chart for a program that calculates the total salary for an employee using this equation: Total_Sal = Salary +Overtime Asma Alosaimi

  10. Solution 10 start Input Salary Overtime Processing Total_Sal = Salary +Overtime Output Total_Sal Read Salary Read Overtime Total_Sal = Salary +Overtime Print Total_Sal End Asma Alosaimi

  11. Example 3 11 Draw a flowchart for a program that determine if the temperature degree is above or below freezing. Input Temp. Processing Check if Temp is below the 32 below freezing. Check if Temp is above the 32 above freezing. Output Print below freezing or above freezing Asma Alosaimi

  12. Solution 12 Asma Alosaimi

  13. Example 4 13 Draw a flowchart for a program that calculates the Zakat, where the user enter the amount of money then the program show the zakat. Zakat =(2.5/100) * amount. Zakat is not calculated if the amount is less than 1000 S.R Asma Alosaimi

  14. Solution 14 Input amount. Processing Check if amount is below 1000 Zakat =0. Check if amount is above 1000 Zakat =(2.5/100) * amount Output Zakat Asma Alosaimi

  15. Solution 15 Start Read amount yes no Amount > 1000 Zakat=0. Zakat=(2.5/100)*amount Print Zakat Asma Alosaimi End

  16. Example 5 16 Draw a flowchart to find the sum of first 50 natural numbers. 1+2+3+ .. +50 Asma Alosaimi

  17. 17 Asma Alosaimi

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#