SlideShare a Scribd company logo
1 of 24
Programming Fundamentals
Assignment-1 Solution Programming Fundamentals | Lecture-9 (m == 3 AND d >= 21) OR (m == 4 AND d <= 19) Period Meaning March 21 – April 19 If Month is 3 then Day must be 21 st  or above Or if Month is 4 then Day must be 19 th  or below
Wrong Decision Rules Programming Fundamentals | Lecture-9 m == 3  OR m == 4 m == 4  OR m == 5 DISPLAY “Aries”
Wrong Decision Rules Programming Fundamentals | Lecture-9 (m == 3 AND  d >= 21 AND d <= 31) (m == 4 AND  d >= 20 AND d <= 30)
Less Better Approach Programming Fundamentals | Lecture-9 m == 3 m == 4 Further rules
Lessons from Previous Lecture ,[object Object],[object Object],Programming Fundamentals | Lecture-9
Lessons from Previous Lecture ,[object Object],Programming Fundamentals | Lecture-9 count = count + 1 count < n count = 0 Yes 1 or more steps
Lessons from Previous Lecture ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Programming Fundamentals | Lecture-9
Lessons from Previous Lecture ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Programming Fundamentals | Lecture-9
Another Example ,[object Object],[object Object],[object Object],[object Object],[object Object],Programming Fundamentals | Lecture-9
Sum of first 5 even numbers Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + count + count
Alternative Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + even even = 0 even = even + 2
Another Example ,[object Object],[object Object],Programming Fundamentals | Lecture-9
Sum of first n odd numbers Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < n count = 0 DISPLAY sum Yes No sum = sum + count + count - 1
Alternative Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + odd odd = -1 odd = odd + 2
Consider This ,[object Object],[object Object],[object Object],Programming Fundamentals | Lecture-9
Display first n even numbers Programming Fundamentals | Lecture-9 START count = count + 1 STOP count < 5 count = 0 Yes No DISPLAY even even = 0 even = even + 2
Another Example ,[object Object],[object Object],[object Object],Programming Fundamentals | Lecture-9
Table of a number up to 10 Programming Fundamentals | Lecture-9 START count = count + 1 STOP count < 10 count = 0 Yes No DISPLAY num * count READ num
Another Example ,[object Object],[object Object],Programming Fundamentals | Lecture-9
Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + count + 25
Testing Programming Fundamentals | Lecture-9 count = 0 sum = 0 Repetition-1 Repetition-2 Repetition-3 Repetition-4 Repetition-5 decision (count < 5) 0 < 5 1 < 5 2 < 5 3 < 5 4 < 5 count  =  count  + 1 1 = 0 + 1 2 = 1 + 1 3 = 2 + 1 4 = 3 + 1 5 = 4 + 1 sum  =  sum  +  count +25 26 =  0 + (1 + 25)   53 =  26 + (2 + 25) 81 =  53 + (3 + 25) 110 =  81 + (4 + 25) 140 =  110 + (5 + 25)
A Challenging Task ,[object Object],[object Object],Programming Fundamentals | Lecture-9
Programming Fundamentals | Lecture-9 BE PREPARED FOR  QUIZ IN NEXT LECTURE

More Related Content

What's hot (17)

Adding and Subtracting Decimals
Adding and Subtracting DecimalsAdding and Subtracting Decimals
Adding and Subtracting Decimals
 
Lesson 19
Lesson 19Lesson 19
Lesson 19
 
Lesson 18
Lesson 18Lesson 18
Lesson 18
 
Adding & Subtracting Decimals
Adding & Subtracting DecimalsAdding & Subtracting Decimals
Adding & Subtracting Decimals
 
Powerpoint on adding and subtracting decimals notes
Powerpoint on adding and subtracting decimals notesPowerpoint on adding and subtracting decimals notes
Powerpoint on adding and subtracting decimals notes
 
Answering Techniques Ad Maths P1
Answering Techniques Ad Maths P1Answering Techniques Ad Maths P1
Answering Techniques Ad Maths P1
 
January 13, 2014
January 13, 2014January 13, 2014
January 13, 2014
 
Triâng. classif. qto lados aula 77 (21-09)
Triâng. classif. qto lados  aula 77 (21-09)Triâng. classif. qto lados  aula 77 (21-09)
Triâng. classif. qto lados aula 77 (21-09)
 
8th pre alg -l78
8th pre alg -l788th pre alg -l78
8th pre alg -l78
 
Sept. 21, 2012
Sept. 21, 2012Sept. 21, 2012
Sept. 21, 2012
 
Tic Tac Toe Factoring
Tic Tac Toe FactoringTic Tac Toe Factoring
Tic Tac Toe Factoring
 
Tafe presentation
Tafe presentationTafe presentation
Tafe presentation
 
7th math c2 -l75
7th math c2 -l757th math c2 -l75
7th math c2 -l75
 
Paperhanging Clculations
Paperhanging Clculations Paperhanging Clculations
Paperhanging Clculations
 
Factoring Trinomials
Factoring TrinomialsFactoring Trinomials
Factoring Trinomials
 
Teoria y problemas de numeros racionales qa84 ccesa007
Teoria y problemas de numeros racionales qa84 ccesa007Teoria y problemas de numeros racionales qa84 ccesa007
Teoria y problemas de numeros racionales qa84 ccesa007
 
Area of Irregular Figures
Area of Irregular FiguresArea of Irregular Figures
Area of Irregular Figures
 

Similar to Cs 1114 - lecture-9

Cs 1114 - lecture-10
Cs 1114 - lecture-10Cs 1114 - lecture-10
Cs 1114 - lecture-10
Zeeshan Sabir
 
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
 
Solving Inequalities01
Solving Inequalities01Solving Inequalities01
Solving Inequalities01
taco40
 
Saxman Hypermedia
Saxman HypermediaSaxman Hypermedia
Saxman Hypermedia
sdsaxman
 
6 2solving Inequalities
6 2solving Inequalities6 2solving Inequalities
6 2solving Inequalities
taco40
 

Similar to Cs 1114 - lecture-9 (20)

Cs 1114 - lecture-8
Cs 1114 - lecture-8Cs 1114 - lecture-8
Cs 1114 - lecture-8
 
Cs 1114 - lecture-10
Cs 1114 - lecture-10Cs 1114 - lecture-10
Cs 1114 - lecture-10
 
Fundamental Programming Lect 3
Fundamental Programming Lect 3Fundamental Programming Lect 3
Fundamental Programming Lect 3
 
Cs 1114 - lecture-3
Cs 1114 - lecture-3Cs 1114 - lecture-3
Cs 1114 - lecture-3
 
Course project solutions 2019
Course project solutions 2019Course project solutions 2019
Course project solutions 2019
 
Cs 1114 - lecture-5
Cs 1114 - lecture-5Cs 1114 - lecture-5
Cs 1114 - lecture-5
 
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
 
4. algorithm
4. algorithm4. algorithm
4. algorithm
 
ppt math6 qt3-wk3.pptx
ppt math6 qt3-wk3.pptxppt math6 qt3-wk3.pptx
ppt math6 qt3-wk3.pptx
 
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
 
Cs 1114 - lecture-7
Cs 1114 - lecture-7Cs 1114 - lecture-7
Cs 1114 - lecture-7
 
sample ppt.ppt
sample ppt.pptsample ppt.ppt
sample ppt.ppt
 
Contéo de figuras
Contéo de figurasContéo de figuras
Contéo de figuras
 
276939732-P66-M1-B12-E.pdf
276939732-P66-M1-B12-E.pdf276939732-P66-M1-B12-E.pdf
276939732-P66-M1-B12-E.pdf
 
15minute-math-integers.ppt
15minute-math-integers.ppt15minute-math-integers.ppt
15minute-math-integers.ppt
 
Solving Inequalities01
Solving Inequalities01Solving Inequalities01
Solving Inequalities01
 
Saxman Hypermedia
Saxman HypermediaSaxman Hypermedia
Saxman Hypermedia
 
6 2solving Inequalities
6 2solving Inequalities6 2solving Inequalities
6 2solving Inequalities
 
Algebra Questions.pdf
Algebra Questions.pdfAlgebra Questions.pdf
Algebra Questions.pdf
 
Math%20repurt
Math%20repurtMath%20repurt
Math%20repurt
 

More from Zeeshan Sabir

More from Zeeshan Sabir (7)

Cs 1114 - lecture-6
Cs 1114 - lecture-6Cs 1114 - lecture-6
Cs 1114 - lecture-6
 
Cs 1114 - lecture-4
Cs 1114 - lecture-4Cs 1114 - lecture-4
Cs 1114 - lecture-4
 
Cs 1114 - lecture-2
Cs 1114 - lecture-2Cs 1114 - lecture-2
Cs 1114 - lecture-2
 
Cs 1114 - lecture-1
Cs 1114 - lecture-1Cs 1114 - lecture-1
Cs 1114 - lecture-1
 
Cs 1114 - lecture-29
Cs 1114 - lecture-29Cs 1114 - lecture-29
Cs 1114 - lecture-29
 
Final logic presentation
Final logic presentationFinal logic presentation
Final logic presentation
 
Human resource management process
Human resource management processHuman resource management process
Human resource management process
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Cs 1114 - lecture-9

  • 2. Assignment-1 Solution Programming Fundamentals | Lecture-9 (m == 3 AND d >= 21) OR (m == 4 AND d <= 19) Period Meaning March 21 – April 19 If Month is 3 then Day must be 21 st or above Or if Month is 4 then Day must be 19 th or below
  • 3. Wrong Decision Rules Programming Fundamentals | Lecture-9 m == 3 OR m == 4 m == 4 OR m == 5 DISPLAY “Aries”
  • 4. Wrong Decision Rules Programming Fundamentals | Lecture-9 (m == 3 AND d >= 21 AND d <= 31) (m == 4 AND d >= 20 AND d <= 30)
  • 5. Less Better Approach Programming Fundamentals | Lecture-9 m == 3 m == 4 Further rules
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Sum of first 5 even numbers Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + count + count
  • 12. Alternative Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + even even = 0 even = even + 2
  • 13.
  • 14. Sum of first n odd numbers Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < n count = 0 DISPLAY sum Yes No sum = sum + count + count - 1
  • 15. Alternative Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + odd odd = -1 odd = odd + 2
  • 16.
  • 17. Display first n even numbers Programming Fundamentals | Lecture-9 START count = count + 1 STOP count < 5 count = 0 Yes No DISPLAY even even = 0 even = even + 2
  • 18.
  • 19. Table of a number up to 10 Programming Fundamentals | Lecture-9 START count = count + 1 STOP count < 10 count = 0 Yes No DISPLAY num * count READ num
  • 20.
  • 21. Programming Fundamentals | Lecture-9 START sum = 0 count = count + 1 STOP count < 5 count = 0 DISPLAY sum Yes No sum = sum + count + 25
  • 22. Testing Programming Fundamentals | Lecture-9 count = 0 sum = 0 Repetition-1 Repetition-2 Repetition-3 Repetition-4 Repetition-5 decision (count < 5) 0 < 5 1 < 5 2 < 5 3 < 5 4 < 5 count = count + 1 1 = 0 + 1 2 = 1 + 1 3 = 2 + 1 4 = 3 + 1 5 = 4 + 1 sum = sum + count +25 26 = 0 + (1 + 25) 53 = 26 + (2 + 25) 81 = 53 + (3 + 25) 110 = 81 + (4 + 25) 140 = 110 + (5 + 25)
  • 23.
  • 24. Programming Fundamentals | Lecture-9 BE PREPARED FOR QUIZ IN NEXT LECTURE