=====
CS 111 - Week 11 Lecture 2 - 2024-11-07
=====
=====
TODAY WE WILL:
=====
* Announcements
* Exam 2 Review
* if time: more on local variables
* prep for next class
* should be working on Homework 9,
at-least-1st-attempts due by 11:59 pm on Friday, November 8
* important upcoming schedule notes!
=====
*** UPDATED these on Wednesday, November 6, after considering
cs50 IDE issues plus other factors ***
=====
* TODAY, Thursday, November 7 - review for Exam 2
* there will again be a handout of review suggestions
* you will again be able to make a handwritten notes
page that you can submit a photo of for bonus credit
and use during the exam
* TOMORROW, Friday, November 8 - WILL be a lab exercise (on switch
statements)
* at-least-first-attempts at Homework 9 due by
11:59 pm on Friday
* TUESDAY, November 12
* graded Exam 1s will be returned during class
(so you can look over them before taking Exam 2!)
* will continue discussing LOCAL VARIABLES and related topics
* ALSO: have your final versions of
Homeworks 7-9 submitted
by 11:59 pm on TUESDAY, November 12,
* WEDNESDAY, November 13
* ...so example solutions can be posted
for Exam 2 study purposes by
12:01 am on WEDNESDAY, November 13
* Raul, CS 111's Learning Assistant,
will give an EXAM 2 REVIEW SESSION on WEDNESDAY, November 13,
in BSS 302 from 3:00 - 5:00 pm
* THURSDAY, November 14 -
* Exam 2 study guide *bonus* is due by 9:00 am on Canvas
* Exam 2 given in class (in GH 218) from 9:00 - 10:20 am
* Friday, November 15 - there WILL be a lab exercise!
* and Homework 10 will come out after this
=====
more on the assignment statement
=====
* syntax:
desired_local_var = desired_compat_expr;
^ ^
left-hand-side right-hand-side
LHS RHS
* the LHS *must* contain something that can be assigned to,
that can be given a value, such as a local variable
* sometimes lvalue is used as a general term to
describe something-that-can-be-assigned-to
* the RHS *must* contain an expression with a value whose
data type is compatible with the data type of the LHS
* semantics:
1. evaluate the RHS expression
2. assign the result to the LHS,
making that the NEW value of the LHS
* replacing whatever value it contained before!
* NOTE: when you use a local variable,
you get its value AT THAT POINT in the program
int quant; // quant is considered undefined
quant = 100; // quant now contains 100
quant = 5 + 10; // quant now contains 15
* so: based on the above, which of these is OK syntactically?
100 = quant; // bAAAAAAAAD!!!!! you can't change the value of 100 !!!
1 + 1 = quant; // NOOOOOOOOO! you can't change the value of 1 + 1 !!!
quant = 1 + 1; // yes, that's fine!
quant = quant + 1; // ALSO fine --
// first compute the value of the RHS:
// * at this point, quant contains 2, so 2 + 1 is 3
// then assign the RHS's value to the LHS
// * so 3 becomes the NEW value of quant