-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d3e5a0
commit 137ccf5
Showing
1 changed file
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,34 @@ class: title | |
|
||
--- | ||
|
||
# Teaching team | ||
|
||
## Teaching assistants | ||
|
||
.center[.teamcols[ | ||
.col[ | ||
[Charel Junior Mangama Sindzi](mailto:[email protected]) ] | ||
.col[ | ||
] | ||
.col[ | ||
] | ||
.col[ | ||
[Yovin Yahathugoda](mailto:[email protected]) ] | ||
] ] | ||
|
||
.center[.teamcols[ | ||
.col[ | ||
[Jakub Grzelak](mailto:[email protected]) ] | ||
.col[ | ||
 ] | ||
.col[ | ||
 ] | ||
.col[ | ||
[Paloma Nashira Rodriguez Baena](mailto:[email protected]) ] | ||
] ] | ||
|
||
--- | ||
|
||
# Course overview | ||
|
||
## Structure | ||
|
@@ -1315,6 +1343,31 @@ arguments to verify that everything works as expected. | |
--- | ||
# Other forms of iteration: `while` & `do ... while` | ||
The `for` loop is by far the most commonly-used looping structure, but others exist and are sometimes more appropriate | ||
-- | ||
The `while` loop takes this form: | ||
``` | ||
while (condition) | ||
statement; | ||
``` | ||
This will keep running `statement` as long as `condition` is true | ||
-- | ||
The `do ... while` loop takes this form: | ||
``` | ||
do | ||
statement; | ||
while (condition); | ||
``` | ||
This will also run `statement` as long as `condition` is true. The difference with the regular `while` loop is that `condition` is tested *after* running `statement` | ||
--- | ||
# The dot operator | ||
In the previous example, you will have noticed the use of syntax of this form: | ||
|
@@ -2321,6 +2374,192 @@ Modify your own code to add these checks, then compile and test it | |
|
||
--- | ||
|
||
# Other forms of conditional execution | ||
|
||
The `if` statement is by far the most common structure for conditional execution, but other forms exist. | ||
|
||
The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form: | ||
``` | ||
switch (variable) { | ||
case value1: | ||
statement; | ||
... | ||
statement; | ||
break; | ||
case value2: | ||
statement; | ||
break; | ||
... | ||
default: | ||
statement; | ||
} | ||
``` | ||
|
||
|
||
--- | ||
|
||
# Other forms of conditional execution | ||
|
||
The `if` statement is by far the most common structure for conditional execution, but other forms exist. | ||
|
||
The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form: | ||
``` | ||
`switch` (variable) { | ||
case value1: | ||
statement; | ||
... | ||
statement; | ||
break; | ||
case value2: | ||
statement; | ||
break; | ||
... | ||
default: | ||
statement; | ||
} | ||
``` | ||
.explain-bottom[ | ||
the `switch` keyword denotes the start of our conditional section of code | ||
] | ||
|
||
|
||
--- | ||
|
||
# Other forms of conditional execution | ||
|
||
The `if` statement is by far the most common structure for conditional execution, but other forms exist. | ||
|
||
The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form: | ||
``` | ||
switch (`variable`) { | ||
case value1: | ||
statement; | ||
... | ||
statement; | ||
break; | ||
case value2: | ||
statement; | ||
break; | ||
... | ||
default: | ||
statement; | ||
} | ||
``` | ||
.explain-bottom[ | ||
`variable` is the variable whose value will determine the code to run | ||
] | ||
|
||
|
||
--- | ||
|
||
# Other forms of conditional execution | ||
|
||
The `if` statement is by far the most common structure for conditional execution, but other forms exist. | ||
|
||
The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form: | ||
``` | ||
switch (variable) { | ||
* case value1: | ||
statement; | ||
... | ||
statement; | ||
break; | ||
case value2: | ||
statement; | ||
break; | ||
... | ||
default: | ||
statement; | ||
} | ||
``` | ||
.explain-bottom[ | ||
for each value of `variable` that we want to handle (e.g `value1`), we use the `case` keyword to label the matching section of code, using this syntax | ||
] | ||
|
||
|
||
--- | ||
|
||
# Other forms of conditional execution | ||
|
||
The `if` statement is by far the most common structure for conditional execution, but other forms exist. | ||
|
||
The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form: | ||
``` | ||
switch (variable) { | ||
case value1: | ||
* statement; | ||
* ... | ||
* statement; | ||
break; | ||
case value2: | ||
statement; | ||
break; | ||
... | ||
default: | ||
statement; | ||
} | ||
``` | ||
.explain-bottom[ | ||
immediately after the `case` label, we insert the code to be run. This can consist of multiple lines – no need for braces here. | ||
] | ||
|
||
|
||
--- | ||
|
||
# Other forms of conditional execution | ||
|
||
The `if` statement is by far the most common structure for conditional execution, but other forms exist. | ||
|
||
The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form: | ||
``` | ||
switch (variable) { | ||
case value1: | ||
statement; | ||
... | ||
statement; | ||
* break; | ||
case value2: | ||
statement; | ||
break; | ||
... | ||
default: | ||
statement; | ||
} | ||
``` | ||
.explain-bottom[ | ||
... but we do need to close off the last statement of the code for that case with the `break` keyword! | ||
|
||
More on the `break` statement shortly... | ||
] | ||
|
||
--- | ||
|
||
# Other forms of conditional execution | ||
|
||
The `if` statement is by far the most common structure for conditional execution, but other forms exist. | ||
|
||
The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form: | ||
``` | ||
switch (variable) { | ||
case value1: | ||
statement; | ||
... | ||
statement; | ||
break; | ||
case value2: | ||
statement; | ||
break; | ||
... | ||
* default: | ||
statement; | ||
} | ||
``` | ||
.explain-middle[ | ||
We can also have a catch-all `default` label at the end, which will be executed in case none of the other labels matched | ||
] | ||
|
||
--- | ||
|
||
# Exercises | ||
|
||
To be added... | ||
|