SlideShare a Scribd company logo
Instructor : Muhammad HarisAll Rights Reserved to Department of Computer Science – GCU Lahore
Programming Fundamentals
Tasks (from previous lecture)
 Calculate area of a rectangle
area = base × height
 Find Cube of a Number
 Calculate Marks Percentage
(marks obtained / total marks) × 100
 Calculate Sales Tax
amount × (tax percent / 100)
 Find “no. of minutes” and “no. of seconds”
for given “no of years”
Programming Fundamentals | Lecture-3 2
Power of Computer Programs
 Once given the input
They perform the instructions (or no. of
steps as instructed by the programmer)
themselves and give the desired output
○ No matter how complex the problem is and
how long they have to work on it
Programming Fundamentals | Lecture-3 3
Now We Will Further Explore Their Power
Consider this Problem
 Find absolute value after subtracting
one number from another
Difference = number1 – number2
Programming Fundamentals | Lecture-3 4
Difference of Two numbers
Programming Fundamentals | Lecture-3 5
START
READ number1, number2
difference = number1 - number2
DISPLAY difference
STOP
Will result in a negative
value if number1 is
smaller than number2
Is This Solution Correct?
Programming Fundamentals | Lecture-3 6
START
READ number1, number2
difference = number1 - number2
DISPLAY difference
STOP
difference = difference * -1
Analyze the Problem
 There exists two conditions
Condition-1
○ Difference is positive
Condition-2
○ Difference is negative
Programming Fundamentals | Lecture-3 7
What is to be Done?
 There exists two conditions
Condition-1
○ Difference is positive
Do not do any conversion, because value is already
positive
Condition-2
○ Difference is negative
Convert it into a positive value by multiplying it by “-1”
Programming Fundamentals | Lecture-3 8
Should we design
two different solutions?
9Programming Fundamentals | Lecture-1
What is Required?
 Need to design a solution in such a way
which can decide for itself whether to
multiply the difference by “-1” or not (by
checking the value of difference)
 The graphical shapes which we have
learned so far are insufficient to provide
this kind of “decision making”
Programming Fundamentals | Lecture-3 10
Decision Box
Programming Fundamentals | Lecture-3 11
Decision
Rule
YesNo
Always in the form
whose answer is
“Yes” or “No”
Programming Fundamentals | Lecture-3 12
START
READ number1, number2
difference = number1 - number2
DISPLAY difference
STOP
difference = difference * -1
difference < 0
YesNo
Power of Computers
 Decision Making
Programmers can instruct computers to
make decisions while solving a problem
○ As the complexity of problems increases,
decision making process become more
extensive
This way computers prove very useful by
performing laborious tasks of decision
making
Programming Fundamentals | Lecture-3 13
Another Example
 Find smaller of two numbers
 Input
number1
number2
 Output
smaller
 Processing
Compare the numbers with each other and
decide which one is smaller
Programming Fundamentals | Lecture-3 14
Programming Fundamentals | Lecture-3 15
START
READ number1, number2
DISPLAY smaller
STOP
smaller = number1
number1 < number2
YesNo
smaller = number2
Alternative
Programming Fundamentals | Lecture-3 16
START
READ number1, number2
STOP
DISPLAY number1
number1 < number2
YesNo
DISPLAY number2
Comparison Operators
 < (less than)
 > (greater than)
 <= (less than equal to)
 >= (greater than equal to)
 == (equal to)
 != (not equal to)
Programming Fundamentals | Lecture-3 17
Output a Message
Programming Fundamentals | Lecture-3 18
DISPLAY “This is a message”
Try it Yourself
 Find whether a number is negative or
not?
 Find whether two numbers are equal or
not?
 Multiply two numbers if their difference
is greater than 0
Programming Fundamentals | Lecture-3 19
Some Keywords
 Look for these keywords in problem
statement in order to determine the
usage of decision box
If
If and only if
Whether
Programming Fundamentals | Lecture-3 20
Tasks (to be done by next 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-3 21
Programming Fundamentals | Lecture-2 22
BE PREPARED
FOR QUIZ
IN
NEXT LECTURE

More Related Content

What's hot

Flowcharts and pseudocodes
Flowcharts and pseudocodesFlowcharts and pseudocodes
Flowcharts and pseudocodes
Dr Piyush Charan
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
Jussi Pohjolainen
 
Theory of programming
Theory of programmingTheory of programming
Theory of programming
tcc_joemarie
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
Allen de Castro
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and FlowchartSPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
Hajar Len
 
Graphical programming
Graphical programmingGraphical programming
Graphical programming
Bilal Maqbool ツ
 
Workshop on programming contest
Workshop on programming contestWorkshop on programming contest
Workshop on programming contest
Abir Khan
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
ALI RAZA
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithem
ehsanullah786
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
DHANIK VIKRANT
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK
 
Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
lotlot
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Sachin Goyani
 
Introduction to Flowchart
Introduction to FlowchartIntroduction to Flowchart
Introduction to Flowchart
ChristopherEsteban2
 
Introduction to problem solving in c++
Introduction to problem solving in c++Introduction to problem solving in c++
Introduction to problem solving in c++
Online
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
Neeru Mittal
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
nicky_walters
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Programming fundamentals lecture 4
Programming fundamentals lecture 4Programming fundamentals lecture 4
Programming fundamentals lecture 4
Raja Hamid
 

What's hot (20)

Flowcharts and pseudocodes
Flowcharts and pseudocodesFlowcharts and pseudocodes
Flowcharts and pseudocodes
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
 
Theory of programming
Theory of programmingTheory of programming
Theory of programming
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and FlowchartSPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Graphical programming
Graphical programmingGraphical programming
Graphical programming
 
Workshop on programming contest
Workshop on programming contestWorkshop on programming contest
Workshop on programming contest
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithem
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Introduction to Flowchart
Introduction to FlowchartIntroduction to Flowchart
Introduction to Flowchart
 
Introduction to problem solving in c++
Introduction to problem solving in c++Introduction to problem solving in c++
Introduction to problem solving in c++
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Programming fundamentals lecture 4
Programming fundamentals lecture 4Programming fundamentals lecture 4
Programming fundamentals lecture 4
 

Viewers also liked

Fundamental Programming Lect 4
Fundamental Programming Lect 4Fundamental Programming Lect 4
Fundamental Programming Lect 4
Namrah Erum
 
Fundamental Programming Lect 5
Fundamental Programming Lect 5Fundamental Programming Lect 5
Fundamental Programming Lect 5
Namrah Erum
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Trivuz ত্রিভুজ
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming Fundamentals
Shahriar Hyder
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)
jakejakejake2
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
 
Chapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of ProgrammingChapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of Programming
ricsanmae
 
Computer programs, flow chart & algorithm
Computer programs, flow chart & algorithmComputer programs, flow chart & algorithm
Computer programs, flow chart & algorithm
samina khan
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
Hossam Hassan
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
Tareq Hasan
 
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
 
C++ ppt
C++ pptC++ ppt
C++ ppt
parpan34
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
 

Viewers also liked (14)

Fundamental Programming Lect 4
Fundamental Programming Lect 4Fundamental Programming Lect 4
Fundamental Programming Lect 4
 
Fundamental Programming Lect 5
Fundamental Programming Lect 5Fundamental Programming Lect 5
Fundamental Programming Lect 5
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming Fundamentals
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
 
Chapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of ProgrammingChapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of Programming
 
Computer programs, flow chart & algorithm
Computer programs, flow chart & algorithmComputer programs, flow chart & algorithm
Computer programs, flow chart & algorithm
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 

Similar to Fundamental Programming Lect 3

Cs 1114 - lecture-10
Cs 1114 - lecture-10Cs 1114 - lecture-10
Cs 1114 - lecture-10
Zeeshan Sabir
 
Cs 1114 - lecture-5
Cs 1114 - lecture-5Cs 1114 - lecture-5
Cs 1114 - lecture-5
Zeeshan Sabir
 
Cs 1114 - lecture-8
Cs 1114 - lecture-8Cs 1114 - lecture-8
Cs 1114 - lecture-8
Zeeshan Sabir
 
Cs 1114 - lecture-9
Cs 1114 - lecture-9Cs 1114 - lecture-9
Cs 1114 - lecture-9
Zeeshan Sabir
 
Cs 1114 - lecture-4
Cs 1114 - lecture-4Cs 1114 - lecture-4
Cs 1114 - lecture-4
Zeeshan Sabir
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
Nuzhat Memon
 
Cs 1114 - lecture-2
Cs 1114 - lecture-2Cs 1114 - lecture-2
Cs 1114 - lecture-2
Zeeshan Sabir
 
Cs 1114 - lecture-7
Cs 1114 - lecture-7Cs 1114 - lecture-7
Cs 1114 - lecture-7
Zeeshan Sabir
 
Covidien Dc Work Keys 101 2
Covidien Dc    Work Keys 101 2Covidien Dc    Work Keys 101 2
Covidien Dc Work Keys 101 2
LauraAtACT
 
How to add and multiply fractions
How to add and multiply fractionsHow to add and multiply fractions
How to add and multiply fractions
brandi28216
 
Saxman Hypermedia
Saxman HypermediaSaxman Hypermedia
Saxman Hypermedia
sdsaxman
 
Course project solutions 2019
Course project solutions 2019Course project solutions 2019
Course project solutions 2019
Robert Geofroy
 
ICT_Seminar_flow_charts_for_2013_Nov.pptx
ICT_Seminar_flow_charts_for_2013_Nov.pptxICT_Seminar_flow_charts_for_2013_Nov.pptx
ICT_Seminar_flow_charts_for_2013_Nov.pptx
ssuser2f67c91
 
Course project solutions 2018
Course project solutions 2018Course project solutions 2018
Course project solutions 2018
Robert Geofroy
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2
Roy Thomas
 
Adding and subtracting positive and negative rational number notes 1
Adding and subtracting positive and negative rational number notes 1Adding and subtracting positive and negative rational number notes 1
Adding and subtracting positive and negative rational number notes 1
citlaly9
 
CSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow ChartsCSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow Charts
Yhal Htet Aung
 
PROBLEM SOLVING TECHNIQUES
PROBLEM SOLVING TECHNIQUESPROBLEM SOLVING TECHNIQUES
PROBLEM SOLVING TECHNIQUES
sudhanagarajan5
 
Flow charts week 5 2020 2021
Flow charts week 5 2020  2021Flow charts week 5 2020  2021
Flow charts week 5 2020 2021
Osama Ghandour Geris
 

Similar to Fundamental Programming Lect 3 (20)

Cs 1114 - lecture-10
Cs 1114 - lecture-10Cs 1114 - lecture-10
Cs 1114 - lecture-10
 
Cs 1114 - lecture-5
Cs 1114 - lecture-5Cs 1114 - lecture-5
Cs 1114 - lecture-5
 
Cs 1114 - lecture-8
Cs 1114 - lecture-8Cs 1114 - lecture-8
Cs 1114 - lecture-8
 
Cs 1114 - lecture-9
Cs 1114 - lecture-9Cs 1114 - lecture-9
Cs 1114 - lecture-9
 
Cs 1114 - lecture-4
Cs 1114 - lecture-4Cs 1114 - lecture-4
Cs 1114 - lecture-4
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
 
Cs 1114 - lecture-2
Cs 1114 - lecture-2Cs 1114 - lecture-2
Cs 1114 - lecture-2
 
Cs 1114 - lecture-7
Cs 1114 - lecture-7Cs 1114 - lecture-7
Cs 1114 - lecture-7
 
Covidien Dc Work Keys 101 2
Covidien Dc    Work Keys 101 2Covidien Dc    Work Keys 101 2
Covidien Dc Work Keys 101 2
 
How to add and multiply fractions
How to add and multiply fractionsHow to add and multiply fractions
How to add and multiply fractions
 
Saxman Hypermedia
Saxman HypermediaSaxman Hypermedia
Saxman Hypermedia
 
Course project solutions 2019
Course project solutions 2019Course project solutions 2019
Course project solutions 2019
 
ICT_Seminar_flow_charts_for_2013_Nov.pptx
ICT_Seminar_flow_charts_for_2013_Nov.pptxICT_Seminar_flow_charts_for_2013_Nov.pptx
ICT_Seminar_flow_charts_for_2013_Nov.pptx
 
Course project solutions 2018
Course project solutions 2018Course project solutions 2018
Course project solutions 2018
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2
 
Adding and subtracting positive and negative rational number notes 1
Adding and subtracting positive and negative rational number notes 1Adding and subtracting positive and negative rational number notes 1
Adding and subtracting positive and negative rational number notes 1
 
CSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow ChartsCSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow Charts
 
PROBLEM SOLVING TECHNIQUES
PROBLEM SOLVING TECHNIQUESPROBLEM SOLVING TECHNIQUES
PROBLEM SOLVING TECHNIQUES
 
Flow charts week 5 2020 2021
Flow charts week 5 2020  2021Flow charts week 5 2020  2021
Flow charts week 5 2020 2021
 

Recently uploaded

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 

Recently uploaded (20)

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 

Fundamental Programming Lect 3

  • 1. Instructor : Muhammad HarisAll Rights Reserved to Department of Computer Science – GCU Lahore Programming Fundamentals
  • 2. Tasks (from previous lecture)  Calculate area of a rectangle area = base × height  Find Cube of a Number  Calculate Marks Percentage (marks obtained / total marks) × 100  Calculate Sales Tax amount × (tax percent / 100)  Find “no. of minutes” and “no. of seconds” for given “no of years” Programming Fundamentals | Lecture-3 2
  • 3. Power of Computer Programs  Once given the input They perform the instructions (or no. of steps as instructed by the programmer) themselves and give the desired output ○ No matter how complex the problem is and how long they have to work on it Programming Fundamentals | Lecture-3 3 Now We Will Further Explore Their Power
  • 4. Consider this Problem  Find absolute value after subtracting one number from another Difference = number1 – number2 Programming Fundamentals | Lecture-3 4
  • 5. Difference of Two numbers Programming Fundamentals | Lecture-3 5 START READ number1, number2 difference = number1 - number2 DISPLAY difference STOP Will result in a negative value if number1 is smaller than number2
  • 6. Is This Solution Correct? Programming Fundamentals | Lecture-3 6 START READ number1, number2 difference = number1 - number2 DISPLAY difference STOP difference = difference * -1
  • 7. Analyze the Problem  There exists two conditions Condition-1 ○ Difference is positive Condition-2 ○ Difference is negative Programming Fundamentals | Lecture-3 7
  • 8. What is to be Done?  There exists two conditions Condition-1 ○ Difference is positive Do not do any conversion, because value is already positive Condition-2 ○ Difference is negative Convert it into a positive value by multiplying it by “-1” Programming Fundamentals | Lecture-3 8
  • 9. Should we design two different solutions? 9Programming Fundamentals | Lecture-1
  • 10. What is Required?  Need to design a solution in such a way which can decide for itself whether to multiply the difference by “-1” or not (by checking the value of difference)  The graphical shapes which we have learned so far are insufficient to provide this kind of “decision making” Programming Fundamentals | Lecture-3 10
  • 11. Decision Box Programming Fundamentals | Lecture-3 11 Decision Rule YesNo Always in the form whose answer is “Yes” or “No”
  • 12. Programming Fundamentals | Lecture-3 12 START READ number1, number2 difference = number1 - number2 DISPLAY difference STOP difference = difference * -1 difference < 0 YesNo
  • 13. Power of Computers  Decision Making Programmers can instruct computers to make decisions while solving a problem ○ As the complexity of problems increases, decision making process become more extensive This way computers prove very useful by performing laborious tasks of decision making Programming Fundamentals | Lecture-3 13
  • 14. Another Example  Find smaller of two numbers  Input number1 number2  Output smaller  Processing Compare the numbers with each other and decide which one is smaller Programming Fundamentals | Lecture-3 14
  • 15. Programming Fundamentals | Lecture-3 15 START READ number1, number2 DISPLAY smaller STOP smaller = number1 number1 < number2 YesNo smaller = number2
  • 16. Alternative Programming Fundamentals | Lecture-3 16 START READ number1, number2 STOP DISPLAY number1 number1 < number2 YesNo DISPLAY number2
  • 17. Comparison Operators  < (less than)  > (greater than)  <= (less than equal to)  >= (greater than equal to)  == (equal to)  != (not equal to) Programming Fundamentals | Lecture-3 17
  • 18. Output a Message Programming Fundamentals | Lecture-3 18 DISPLAY “This is a message”
  • 19. Try it Yourself  Find whether a number is negative or not?  Find whether two numbers are equal or not?  Multiply two numbers if their difference is greater than 0 Programming Fundamentals | Lecture-3 19
  • 20. Some Keywords  Look for these keywords in problem statement in order to determine the usage of decision box If If and only if Whether Programming Fundamentals | Lecture-3 20
  • 21. Tasks (to be done by next 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-3 21
  • 22. Programming Fundamentals | Lecture-2 22 BE PREPARED FOR QUIZ IN NEXT LECTURE