SlideShare a Scribd company logo
Instructor : Muhammad HarisAll Rights Reserved to Department of Computer Science – GCU Lahore
Programming Fundamentals
Recap of Previous Lectures
 To solve a problem using computers, we
need to do the following:
1. Define the problem (in terms of inputs,
outputs and processing)
2. Design a solution for it (using a graphical
approach)
○ Symbols used
 Oval – Start and Stop
 Parallelogram – Input and Output
 Rectangle - Processing
 Diamond - Decision box
Programming Fundamentals | Lecture-4 2
Recap of Previous Lectures
 Problems we looked at
Sum, Product, Difference of two numbers
Square or cube of a number
Solving an equation or a formula involving 3,
4 variables
○ Example
Some formulae from elementary physics or an
algebraic equation
Programming Fundamentals | Lecture-4 3
Recap of Previous Lectures
 Decision making is required in many
real-world problems
Computer programs can be very useful in
this regard
 To incorporate decision making in our
solutions we learnt the usage of
“Decision box”
Programming Fundamentals | Lecture-4 4
Decision
Rule
YesNo
Always in the form
whose answer is
“Yes” or “No”
Recap of Previous Lectures
 We always make comparisons in a
decision box or Decision Rules are
always in the form of comparisons
Examples
○ difference < 0
○ sum > 0
○ number2 != 0
○ marks >= 50
Programming Fundamentals | Lecture-4 5
Recap of Previous Lectures
 To determine the usage of decision rule,
follow these steps
1. Define inputs and outputs
2. Is decision-making required in this
solution?
3. What are the basis of decision?
○ the thing which is required to make a
decision will appear in the decision box
1. What kind of comparison is required in the
decision box?
Programming Fundamentals | Lecture-4 6
Recap of Previous Lectures
 Problems we looked at
Checking negativity of a number
Checking equality of two numbers
Multiplying or Dividing two numbers
conditionally
Checking status of a student
Programming Fundamentals | Lecture-4 7
Tasks (from previous lecture)
 Find whether the sum of two numbers is
greater than 50
 Find whether the sum of two numbers is
greater than the third number?
 Divide a number by another if only if the
second number is not equal to “0”
 Determine whether a student is “passed” or
“failed” from his marks
A student securing marks less than 50 is
considered “failed”
Programming Fundamentals | Lecture-4 8
Decision Rules
 So far
1 decision rule in a decision box
Examples
○ difference < 0
○ number2 != 0
○ marks < 50
Programming Fundamentals | Lecture-4 9
difference < 0 number2 != 0 marks< 50
Consider This Example
 Divide a number by another if the
second number is greater than “0” and
less than “10”
 Divide a number by another if the
second number is between “0” and “10”
(also known as range check)
Programming Fundamentals | Lecture-4 10
OR
Programming Fundamentals | Lecture-4 11
START
READ num1, num2
DISPLAY answer
STOP
answer = num1 / num2
num2 > 0
YesNo
More than 1 Decision Rule
Programming Fundamentals | Lecture-4 12
START
READ num1, num2
DISPLAY answer
STOP
answer = num1 / num2
num2 > 0 AND
num2 < 10
YesNo
Another Example
 Add two numbers if either of them is “0”
Programming Fundamentals | Lecture-4 13
Another Example
 Determine status of a Students from
marks of two of his subjects
If marks for both the subjects are greater
than 40 he’s considered passed
Programming Fundamentals | Lecture-4 14
Another Example
 Determine status of a Students from
marks of two of his subjects
If marks for any of the subjects is greater
than 40 he’s considered passed
Programming Fundamentals | Lecture-4 15
Programming Fundamentals | Lecture-4 16
BE PREPARED
FOR
ON-THE-SPOT TEST
IN
NEXT LECTURE

More Related Content

PPT
Fundamental Programming Lect 5
PPT
Fundamental Programming Lect 3
PPT
Fundamental Programming Lect 2
PPTX
Programming fundamentals lecture 1 0f c
PPTX
Programming fundamentals lecture 2 of c
PPT
Cs 1114 - lecture-3
PPT
Introduction to problem solving in c++
PPTX
Flowcharts and pseudocodes
Fundamental Programming Lect 5
Fundamental Programming Lect 3
Fundamental Programming Lect 2
Programming fundamentals lecture 1 0f c
Programming fundamentals lecture 2 of c
Cs 1114 - lecture-3
Introduction to problem solving in c++
Flowcharts and pseudocodes

What's hot (20)

PPTX
Introduction to problem solving in C
PPT
Class 7 lecture notes
PPT
PPT
Cs 1114 - lecture-4
PPT
2.3 Apply the different types of algorithm to solve problem
PDF
Fundamentals of programming)
PPT
Problem solving using Computer
PPT
Problem Solving Techniques
PPT
Data structures & problem solving unit 1 ppt
PPTX
Competitive Programming Guide
PPT
Cs 1114 - lecture-5
PDF
Problem solving (C++ Programming)
PPTX
Flowchart and algorithem
PPT
Covidien Dc Work Keys 101 2
PPTX
Algorithm and flowchart
PPTX
Algorithm &amp; flowchart
PPTX
2.1 Understand problem solving concept
PPT
An introduction to Competitive Programming
PPT
03 algorithm properties
PPTX
Algorithm and flowchart2010
Introduction to problem solving in C
Class 7 lecture notes
Cs 1114 - lecture-4
2.3 Apply the different types of algorithm to solve problem
Fundamentals of programming)
Problem solving using Computer
Problem Solving Techniques
Data structures & problem solving unit 1 ppt
Competitive Programming Guide
Cs 1114 - lecture-5
Problem solving (C++ Programming)
Flowchart and algorithem
Covidien Dc Work Keys 101 2
Algorithm and flowchart
Algorithm &amp; flowchart
2.1 Understand problem solving concept
An introduction to Competitive Programming
03 algorithm properties
Algorithm and flowchart2010
Ad

Viewers also liked (8)

PPT
Fundamental Programming Lect 1
PPTX
Computer programs, flow chart & algorithm
PPTX
Programming Fundamentals
PPT
01 c++ Intro.ppt
PPTX
Functional Programming Fundamentals
PPT
20. Object-Oriented Programming Fundamental Principles
PPTX
C++ ppt
PPT
Basics of c++ Programming Language
Fundamental Programming Lect 1
Computer programs, flow chart & algorithm
Programming Fundamentals
01 c++ Intro.ppt
Functional Programming Fundamentals
20. Object-Oriented Programming Fundamental Principles
C++ ppt
Basics of c++ Programming Language
Ad

Similar to Fundamental Programming Lect 4 (20)

PPT
Cs 1114 - lecture-7
PDF
Four 4s lesson_plan
PPT
Cs 1114 - lecture-10
PPTX
Introduction to basic programming repetition
PPTX
Consolidation-Camp-Math-Lesson-2.pptx
PPT
Thinking and working mathematically
PPT
Design and Analysis of algorithms unit 1 notes
PPT
Nota Item Analysis Essay ,jenis-jenis soalan
PDF
9th Comp Ch 1 LQ.pdf
PPTX
Overview of Business Math
DOCX
design of experiments.docx
PPT
Cs 1114 - lecture-8
PDF
CSC1100 - Chapter12 - Flow Charts
PPTX
Smart Strategy for SAT Preparation
PPT
Demo class
PPTX
ESIT135 : Unit 1 Python Basics Concepts
PDF
Lasson planww_-_docx
PDF
Lasson plan_-_docx11
PPTX
Learning
PPT
Cs 1114 - lecture-6
Cs 1114 - lecture-7
Four 4s lesson_plan
Cs 1114 - lecture-10
Introduction to basic programming repetition
Consolidation-Camp-Math-Lesson-2.pptx
Thinking and working mathematically
Design and Analysis of algorithms unit 1 notes
Nota Item Analysis Essay ,jenis-jenis soalan
9th Comp Ch 1 LQ.pdf
Overview of Business Math
design of experiments.docx
Cs 1114 - lecture-8
CSC1100 - Chapter12 - Flow Charts
Smart Strategy for SAT Preparation
Demo class
ESIT135 : Unit 1 Python Basics Concepts
Lasson planww_-_docx
Lasson plan_-_docx11
Learning
Cs 1114 - lecture-6

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Getting Started with Data Integration: FME Form 101
Encapsulation_ Review paper, used for researhc scholars
Machine Learning_overview_presentation.pptx
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
cuic standard and advanced reporting.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding

Fundamental Programming Lect 4

  • 1. Instructor : Muhammad HarisAll Rights Reserved to Department of Computer Science – GCU Lahore Programming Fundamentals
  • 2. Recap of Previous Lectures  To solve a problem using computers, we need to do the following: 1. Define the problem (in terms of inputs, outputs and processing) 2. Design a solution for it (using a graphical approach) ○ Symbols used  Oval – Start and Stop  Parallelogram – Input and Output  Rectangle - Processing  Diamond - Decision box Programming Fundamentals | Lecture-4 2
  • 3. Recap of Previous Lectures  Problems we looked at Sum, Product, Difference of two numbers Square or cube of a number Solving an equation or a formula involving 3, 4 variables ○ Example Some formulae from elementary physics or an algebraic equation Programming Fundamentals | Lecture-4 3
  • 4. Recap of Previous Lectures  Decision making is required in many real-world problems Computer programs can be very useful in this regard  To incorporate decision making in our solutions we learnt the usage of “Decision box” Programming Fundamentals | Lecture-4 4 Decision Rule YesNo Always in the form whose answer is “Yes” or “No”
  • 5. Recap of Previous Lectures  We always make comparisons in a decision box or Decision Rules are always in the form of comparisons Examples ○ difference < 0 ○ sum > 0 ○ number2 != 0 ○ marks >= 50 Programming Fundamentals | Lecture-4 5
  • 6. Recap of Previous Lectures  To determine the usage of decision rule, follow these steps 1. Define inputs and outputs 2. Is decision-making required in this solution? 3. What are the basis of decision? ○ the thing which is required to make a decision will appear in the decision box 1. What kind of comparison is required in the decision box? Programming Fundamentals | Lecture-4 6
  • 7. Recap of Previous Lectures  Problems we looked at Checking negativity of a number Checking equality of two numbers Multiplying or Dividing two numbers conditionally Checking status of a student Programming Fundamentals | Lecture-4 7
  • 8. Tasks (from previous lecture)  Find whether the sum of two numbers is greater than 50  Find whether the sum of two numbers is greater than the third number?  Divide a number by another if only if the second number is not equal to “0”  Determine whether a student is “passed” or “failed” from his marks A student securing marks less than 50 is considered “failed” Programming Fundamentals | Lecture-4 8
  • 9. Decision Rules  So far 1 decision rule in a decision box Examples ○ difference < 0 ○ number2 != 0 ○ marks < 50 Programming Fundamentals | Lecture-4 9 difference < 0 number2 != 0 marks< 50
  • 10. Consider This Example  Divide a number by another if the second number is greater than “0” and less than “10”  Divide a number by another if the second number is between “0” and “10” (also known as range check) Programming Fundamentals | Lecture-4 10 OR
  • 11. Programming Fundamentals | Lecture-4 11 START READ num1, num2 DISPLAY answer STOP answer = num1 / num2 num2 > 0 YesNo
  • 12. More than 1 Decision Rule Programming Fundamentals | Lecture-4 12 START READ num1, num2 DISPLAY answer STOP answer = num1 / num2 num2 > 0 AND num2 < 10 YesNo
  • 13. Another Example  Add two numbers if either of them is “0” Programming Fundamentals | Lecture-4 13
  • 14. Another Example  Determine status of a Students from marks of two of his subjects If marks for both the subjects are greater than 40 he’s considered passed Programming Fundamentals | Lecture-4 14
  • 15. Another Example  Determine status of a Students from marks of two of his subjects If marks for any of the subjects is greater than 40 he’s considered passed Programming Fundamentals | Lecture-4 15
  • 16. Programming Fundamentals | Lecture-4 16 BE PREPARED FOR ON-THE-SPOT TEST IN NEXT LECTURE