Strings, Conditionals, Logical Operators

Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=_hbq0rAXvIs



Category:
Vlog
Duration: 1:12:52
250 views
1


Today we learned a few very important things:


1) = is used to assign a value to a variable


2) A "scope" is defined by a {} pair, and is the home of a variable. You can make at most one variable with the same name in a scope



3) Ints range from -2.1B to 2.1B; floats have error in them



4) if statements can be used to do one thing or another. You can use if / else if / else blocks to do different things in different situations.



5) Inside an if statement's parenthesis () you can put comparison operators, like if (x == 5), and so if x is five, it will run the code in the scope after it. You can do less than, greater than, less than or equal to, greater than or equal to, equal to (== is comparison, = is assignment!!!) and not equal to (!=).


6) If you want more complex comparisons, you can join together multiple comparison operations with logical operators: and (&&), or (||) and not (!)



7) Strings hold zero or more characters, and are used to hold things like names and addresses. When you do a cin statement into a string you get one word (so if you type in "Bob Hope" the cin will read only "Bob" and leave "Hope" in the input buffer for the next cin).







Tags:
csci 40
strings
conditionals
c++
logical operators
comparisons
branches
if statements
overflow
ints
floats