lecture 4
play

Lecture 4 4 September 2018 Admin Matters Unit 8: If Else Unit 9: - PowerPoint PPT Presentation

Lecture 4 4 September 2018 Admin Matters Unit 8: If Else Unit 9: Logical Expression Unit 10: Assertion How to do badly in CS1010 AY18/19 Sem 1 1. Ignore what Wei Tsang advised or announced during lecture AY18/19 Sem 1 2. Do not read / pay


  1. Lecture 4 4 September 2018 Admin Matters Unit 8: If Else Unit 9: Logical Expression Unit 10: Assertion

  2. How to do badly in CS1010 AY18/19 Sem 1

  3. 1. Ignore what Wei Tsang advised or announced during lecture AY18/19 Sem 1

  4. 2. Do not read / pay attention to the guides and notes posted on CS1010 website AY18/19 Sem 1

  5. 3. Visit Piazza only when you have a question to ask yourself AY18/19 Sem 1

  6. 4. Wait for others to ask questions AY18/19 Sem 1

  7. 5. Wait for solutions from UDLs instead of trying the problems yourself. AY18/19 Sem 1

  8. 6. Expect assignments / tests / exams to be similar to problem sets / exercises AY18/19 Sem 1

  9. 7. Copy-paste sample code from lecture instead of writing it out yourself AY18/19 Sem 1

  10. Tutorial 3 
 Problem Sets from Unit 8-9 Today AY18/19 Sem 1

  11. Assignment 1 
 Arithmetic Ops Recursive Function 
 If-Else AY18/19 Sem 1

  12. Assignment 1 
 Released this Friday Due next Friday AY18/19 Sem 1

  13. Practical Exam 1 Your venue will be announced on Piazza soon. Acclimatize yourself. AY18/19 Sem 1

  14. Midterm Venue: MPSH 1 (B) 2 October 4pm - 6pm AY18/19 Sem 1

  15. Catch Up Session This Saturday UNIX / vim (the basic) AY18/19 Sem 1

  16. Catch Up Session Must have read through the UNIX tutorial and have gone through vimtutor. AY18/19 Sem 1

  17. Catch Up Session Please register online by end of tomorrow. (see Piazza post) AY18/19 Sem 1

  18. Reminder Use XShell on the PCs in our labs to ssh into the PE hosts and code. AY18/19 Sem 1

  19. Reminder Read plagiarism and late submission policy on the CS1010 website. AY18/19 Sem 1

  20. Readings Overview about your programming assignments. AY18/19 Sem 1

  21. https://kahoot.it AY18/19 Sem 1

  22. long square(long x) { return x*x; } double hypotenuse_of(long base, long height) { return sqrt(square(base) + square(height)); } int main() { : hypotenuse = hypotenuse_of(base, height); : }

  23. Where are we in CS1010? Problem Solving C language / syntax Behavioural / Mental model Tools / Good Practice

  24. Where are we in CS1010? Problem Solving C language / syntax decomposition recursion flowchart Behavioural / Mental model Tools / Good Practice

  25. Where are we in CS1010? Problem Solving C language / syntax decomposition types in C recursion functions in C flowchart arithmetic ops Behavioural / Mental model Tools / Good Practice

  26. Where are we in CS1010? Problem Solving C language / syntax decomposition types in C recursion functions in C flowchart arithmetic ops Behavioural / Mental model Tools / Good Practice machine code data in memory types

  27. Where are we in CS1010? Problem Solving C language / syntax decomposition types in C recursion functions in C flowchart arithmetic ops Behavioural / Mental model Tools / Good Practice machine code clang data in memory vim types bash

  28. Today Problem Solving C language / syntax decomposition types in C recursion functions in C flowchart 
 arithmetic ops conditionals if else assertion logical expressions Behavioural / Mental model Tools / Good Practice machine code clang data in memory vim types bash

  29. Lecture 4 4 September 2018 Admin Matters Unit 8: If Else Unit 9: Logical Expression Unit 10: Assertion

  30. input k and l 0 ..l k-1 i m = l 0 is l i > m ? m = l i i += 1 equals k? i = 1 NO YES YES NO return m

  31. input n return 
 n equals 0 ? n * factorial(n-1) NO YES return 1

  32. long factorial(long n) { if (n == 0) { return 1; } return n * factorial(n - 1); }

  33. Need to reason about all possibilities AY18/19 Sem 1

  34. Score Letter Grade 8 or higher A Less than 8 B but 5 or higher Less than 5 C but 3 or higher Less than 3 D

  35. Score Letter Grade 8 or higher A Less than 8 See Table 1 Table 1 (Less than 8) Score Letter Grade 5 or higher B Less than 5 See Table 2

  36. Table 1 (Less than 8) Score Letter Grade 5 or higher B Less than 5 See Table 2 Table 2 (Less than 5) Score Letter Grade 3 or higher C Less than 3 D

  37. if (score >= 8) if (late_penalty != 0) cs1010_println_string("late submission”); else cs1010_println_string("you can do better!”);

  38. if (score >= 8) { if (late_penalty != 0) { cs1010_println_string("late submission”); } else { cs1010_println_string("you can do better!”); } } if (score >= 8) { if (late_penalty != 0) { cs1010_println_string("late submission”); } } else { cs1010_println_string("you can do better!”); }

  39. The bool data type can take two values true or false AY18/19 Sem 1

  40. #include <stdbool.h> AY18/19 Sem 1

  41. && || !

Recommend


More recommend