Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cs 1114 - lecture-6

508 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Cs 1114 - lecture-6

  1. 1. Programming Fundamentals
  2. 2. Programming Fundamentals | Lecture-6 Yes No AND All are True Any of them or all of them are not True OR Any of them or all of them are True All are not True
  3. 3. Consider this Example <ul><li>For given marks of two subjects of a student, do the following: </li></ul><ul><ul><li>If marks for either of the subjects are greater than or equal to 40 </li></ul></ul><ul><ul><ul><li>He is considered passed </li></ul></ul></ul><ul><ul><li>If marks for subject 1 are >= 40 </li></ul></ul><ul><ul><ul><li>Display that he is “Passed due to subject 1” </li></ul></ul></ul><ul><ul><li>If marks for subject 2 are >= 40 </li></ul></ul><ul><ul><ul><li>Display that he is “Passed due to subject 2” </li></ul></ul></ul><ul><ul><li>If marks for both the subjects are >= 40 </li></ul></ul><ul><ul><ul><li>Display that he is “Passed due to both subjects” </li></ul></ul></ul>Programming Fundamentals | Lecture-6
  4. 4. Programming Fundamentals | Lecture-6 START READ m1, m2 m1 >= 40 OR m2 >= 40 Yes No DISPLAY “Failed” m1>= 40 AND m2 >= 40 No m1>= 40 Yes No DISPLAY “Passed due to subject 1” DISPLAY “Passed due to subject 2” DISPLAY “Passed due to both subjects” Yes
  5. 5. Consider this Example <ul><li>For given marks of two subjects of a student, do the following: </li></ul><ul><ul><li>If marks for both the subjects are greater than or equal to 40 </li></ul></ul><ul><ul><ul><li>Display that he is “Passed” </li></ul></ul></ul><ul><ul><li>If marks for subject 1 are less than 40 </li></ul></ul><ul><ul><ul><li>Display that he is “Failed due to subject 1” </li></ul></ul></ul><ul><ul><li>If marks for subject 2 are less than 40 </li></ul></ul><ul><ul><ul><li>Display that he is “Failed due to subject 2” </li></ul></ul></ul><ul><ul><li>If marks for both the subjects are less than 40 </li></ul></ul><ul><ul><ul><li>Display that he is “Failed due to both subjects” </li></ul></ul></ul>Programming Fundamentals | Lecture-6
  6. 6. Programming Fundamentals | Lecture-6 START READ m1, m2 m1 >= 40 AND m2 >= 40 Yes No DISPLAY “Passed” m1< 40 AND m2 < 40 Yes No DISPLAY “Failed due to both subjects” DISPLAY “Failed due to subject 2” m1< 40 Yes DISPLAY “Failed due to subject 1” No
  7. 7. An Important Point <ul><li>Compare the two Examples </li></ul><ul><ul><li>Problem-1: Find “Winter” season from given month number </li></ul></ul><ul><ul><ul><li>Only one scenario </li></ul></ul></ul><ul><ul><li>Problem-2: Find “Day” from given day no </li></ul></ul><ul><ul><ul><li>More than 1 scenarios </li></ul></ul></ul>Programming Fundamentals | Lecture-6
  8. 8. Try it Yourself <ul><li>Find the season from given month number </li></ul>Programming Fundamentals | Lecture-6 Month Number Season 1 Winter 2 Winter 3 Spring 4 Spring 5 Spring 6 Summer 7 Summer 8 Summer 9 Fall 10 Fall 11 Fall 12 Winter
  9. 9. Another Example <ul><li>Find grade from given marks of a Student </li></ul>Programming Fundamentals | Lecture-6 Marks Range Grade 90 or above A+ 85 to 89 A 75 to 84 B 65 to 74 C 50 to 64 D Below 50 F
  10. 10. Consider this Example <ul><li>Find smallest of three numbers </li></ul>Programming Fundamentals | Lecture-6

×