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

lecture 4
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1
slide-2
SLIDE 2

Lecture 4

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

slide-3
SLIDE 3

AY18/19 Sem 1

How to do badly in CS1010

slide-4
SLIDE 4

AY18/19 Sem 1

1. Ignore what Wei Tsang advised or announced during lecture

slide-5
SLIDE 5

AY18/19 Sem 1

2. Do not read / pay attention to the guides and notes posted on CS1010 website

slide-6
SLIDE 6

AY18/19 Sem 1

3. Visit Piazza only when you have a question to ask yourself

slide-7
SLIDE 7

AY18/19 Sem 1

4. Wait for others to ask questions

slide-8
SLIDE 8

AY18/19 Sem 1

5. Wait for solutions from UDLs instead of trying the problems yourself.

slide-9
SLIDE 9

AY18/19 Sem 1

6. Expect assignments / tests / exams to be similar to problem sets / exercises

slide-10
SLIDE 10

AY18/19 Sem 1

7. Copy-paste sample code from lecture instead of writing it out yourself

slide-11
SLIDE 11

AY18/19 Sem 1

Tutorial 3
 Problem Sets from Unit 8-9 Today

slide-12
SLIDE 12

AY18/19 Sem 1

Assignment 1


Arithmetic Ops Recursive Function
 If-Else

slide-13
SLIDE 13

AY18/19 Sem 1

Assignment 1


Released this Friday Due next Friday

slide-14
SLIDE 14

AY18/19 Sem 1

Practical Exam 1

Your venue will be announced on Piazza soon. Acclimatize yourself.

slide-15
SLIDE 15

AY18/19 Sem 1

Midterm

Venue: MPSH 1 (B) 2 October 4pm - 6pm

slide-16
SLIDE 16

AY18/19 Sem 1

Catch Up Session This Saturday UNIX / vim (the basic)

slide-17
SLIDE 17

AY18/19 Sem 1

Catch Up Session Must have read through the UNIX tutorial and have gone through vimtutor.

slide-18
SLIDE 18

AY18/19 Sem 1

Catch Up Session Please register online by end of tomorrow. (see Piazza post)

slide-19
SLIDE 19

AY18/19 Sem 1

Reminder Use XShell on the PCs in our labs to ssh into the PE hosts and code.

slide-20
SLIDE 20

AY18/19 Sem 1

Reminder Read plagiarism and late submission policy on the CS1010 website.

slide-21
SLIDE 21

AY18/19 Sem 1

Readings Overview about your programming assignments.

slide-22
SLIDE 22

AY18/19 Sem 1

https://kahoot.it

slide-23
SLIDE 23

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); : }

slide-24
SLIDE 24

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

slide-25
SLIDE 25

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

slide-26
SLIDE 26

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

slide-27
SLIDE 27

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

slide-28
SLIDE 28

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

slide-29
SLIDE 29

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

slide-30
SLIDE 30

Lecture 4

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

slide-31
SLIDE 31

m = l0 i = 1 i equals k? return m

YES

is li > m ? m = li i += 1

YES NO NO

input k and l0..lk-1

slide-32
SLIDE 32

n equals 0? return 1

NO YES

input n return 
 n * factorial(n-1)

slide-33
SLIDE 33

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

slide-34
SLIDE 34

AY18/19 Sem 1

Need to reason about all possibilities

slide-35
SLIDE 35

Score Letter Grade

8 or higher A Less than 8 but 5 or higher B Less than 5 but 3 or higher C Less than 3 D

slide-36
SLIDE 36

Score Letter Grade

5 or higher B Less than 5 See Table 2

Score Letter Grade

8 or higher A Less than 8 See Table 1

Table 1 (Less than 8)

slide-37
SLIDE 37

Score Letter Grade

5 or higher B Less than 5 See Table 2

Table 1 (Less than 8) Table 2 (Less than 5)

Score Letter Grade

3 or higher C Less than 3 D

slide-38
SLIDE 38

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

slide-39
SLIDE 39

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!”); }

slide-40
SLIDE 40

AY18/19 Sem 1

The bool data type can take two values true or false

slide-41
SLIDE 41

AY18/19 Sem 1

#include <stdbool.h>

slide-42
SLIDE 42

&& || !