In-class notes for 09/17/2018
CS 251 (SD), Fall 2018
Quiz Wednesday
Reading question form now available - see links in homework
Submit at least one question per reading, from now on
mark as "high priority" when desired
Quiz topics for Wednesday:
Memory diagrams. See the puzzles page for the in-class puzzles with solutions we've shown in class.
Note that the quiz memory-diagram problems will focus on your understanding of how the computer carries out C++ instructions, so there won't be information you couldn't know, e.g., the ASCII code for letter 'o', or how roundoff error gives an unexpected result in the answer to
FloatExample.cpp
C++ programming with variable definitions, assignments,
cout
output, etc. Standard types (int, long, float, double, char
), basic operators (+, -, *, /, =
), syntax for basic structure of a program.
Reading questions
Some definitions:
A function is a procedure of computer actions that may have 0 or more arguments and 0 or 1 return values.
A function call is a language expression for causing a function to perform its computer actions. E.g.,
sqrt(3)
.The scope of an identifier is the range of code in which that identifier has meaning.
The state change of a function consists of all effects that function has, apart from its return value.
An operator is a function with specialized syntax for its calls. In C++, an operator call (such as
x+3
) can alternatively be written using th usual syntax for a function call (e.g.,operator+(x, 3)
.
Puzzles
Example: Memory diagram for
#include <iostream > using namespace std; int add1(int n) { return n+1; } int main() { float pi = 3.14; int z; z = add1(pi); cout << pi << " " << z << endl; }
Func1.cpp
Func2.cpp