7.9 KiB
7.9 KiB
Notes for the class
Index of files written in class
-
Lecture 1
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/hello.cpp Hello, World!
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/echo.cpp A program that reads in a string and prints it back out
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/order.cpp Pizza ordering program, like a harder version of the tipping program in Coding Assignment 1
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/adder.cpp A program that reads two numbers in, adds them together, then prints a result
-
Lecture 2
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/averager.cpp A program that reads two numbers in and averages them, similar to Coding Assignment 1
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/inverter.cpp A program that reads in a number and returns one divided by that number (unless the number is zero). First introduction to if-statements.
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/choosing.cpp A program that demonstrates more about how if-statements work, might be useful for Coding Assignment 1
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/looping.cpp A first introduction to while loops. A program that loops over and over until you enter a number greater than 10
-
Lecture 3
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/table.cpp Our big extended example of how to make a table in c++ with iomanip functions
-
Lecture 4
- A demonstration of how to use random number generation in c++ https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/randomTest.cpp
- Our guessing game that uses a while-loop to keep asking until you've guessed the correct number (this one has the ability to limit the max number of guesses) https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/guessing.cpp
- How to use
for
: https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/for1.cpp - Here's an example of how to use for to sum up a bunch of numbers (might be helpful for an assignment…): https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/forInput.cpp
-
Lecture 5
- An example of using
while
to read in an input: https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/whileCin1.cpp - An example of using
while
to re-ask for an input until it is the correct form (very helpful for coding assignment 2)! https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/whileCin2.cpp
- An example of using
-
Lecture 6
- An example of how arrays don't stop you from accessing out of bounds elements: https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/badarray.cpp
- An example of how to properly use arrays: https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/array1.cpp
- An example that shows how
cin.fail()
can be used to detect whether there was an error in the parsing of input: https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/cinfail.cpp - An example that shows how to correctly parse only integers using a while loop with cin.fail and cin.peek() to look for a '.': https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/cinfail2.cpp
- An example that shows how to abstract the code from the previous example into multiple functions, one that reads in an
int
and one that reads indouble
s: https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/cinfail3.cpp - An example how to use
getline
to read in input that has spaces: https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/getlinetest.cpp -
The following are out-of-lecture examples of how to properly handle data validation for inputs
-
Lecture (2/14/2024)
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/fun1.cpp demo of functions!
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/flipgame.cpp example program that might be useful for getting started with assignment 3!
-
Lecture ??? (honestly I don't remember which lecture exactly these were, mea culpa)
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/array2.cpp An example of writing a function that loops through an array
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/array3.cpp An example of using "parallel" arrays, in other words multiple arrays to represent "rows" of data
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/find1.cpp An example of using the string method
find
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/fun2.cpp An example of pass by reference vs. pass by value
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/prototype1.cpp An example of using prototypes of functions
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/sarcasmCase.cpp An example of using a loop through a string to make a silly function
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/substring.cpp An example of using the substr function
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/switch1.cpp A first example of switch/case statements
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/tostr.cpp Using
to_string
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/whileRef.cpp Using pass by ref to write a new averaging function
-
Lecture (2/26/2024)
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/switch2.cpp More examples of using switches that might be useful for assignment 4
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/switchLoop.cpp Another example of switches that will be useful for assignment 4
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/switchswitch.cpp Nested switches
-
Lecture (2/28/2024)
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/mistake1.cpp talking about easy to make mistakes such as accidentally mixing up = and ==
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/nestedfor.cpp nested for loops
-
Lecture (3/6/2024)
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/palfor.cpp a simple version of palindrome finding for single words
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/arrayofarrays.cpp an examples of how an array of strings would work, this example shows how to find the acrostic of a set of sentences (well, just individual words you can change the code to use getline to make it work with whole sentences)
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/whileArray.cpp this is an example of how to traverse an array only partially with a while-loop rather than a for loop
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/palWithSpaces.cpp an example of how to solve discussion for in a single while loop
-
Lecture (3/11/2024)
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/rectRef.cpp A file where we show more about pass-by-reference and give a taste of structs
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/byRef.cpp A file where we show how to use pass-by-reference to simplify the logical structure of a file
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/byVal.cpp A file where we show a pass-by-value version of the above program
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/arrayRef.cpp Hey, why don't you have to pass arrays by reference??
- https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/arrayTheTruth.cpp Arrays were pointers all along