# Final Review

Tom Kelliher, CS17

May 16, 1996

1. Loops:
1. Counter-, sentinel-controlled.
2. Pre-, Post-test.
3. for loop: initialization, condition, post-processing.
4. while, do while.
5. break, continue.
6. Nested loops.
7. Essential equivalence of the three constructs.
2. Reference variables, parameters:
1. Variable: alias for a ``real'' variable.
2. Parameter: alias for the actual parameter.
3. Two types of parameters:
1. Call-by-value: formal parameter is a copy of the actual parameter. Actual parameter can be any expression of appropriate type.
2. Call-by-reference: formal parameter is an alias for the actual parameter. Actual parameter must be a variable of the appropriate type.
3. Simple example:
```void f(int& a, int b)
{
++a;
++b;
}

int main()
{
int i = 0;
int j = 0;

f(i, j);
cout << setw(10) << i << setw(10) << j << endl;
f(1, j);
cout << setw(10) << i << setw(10) << j << endl;
f(i, 1);
cout << setw(10) << i << setw(10) << j << endl;

return 0;
}
```

4. Example combined with scope, visibility:
```int i = 0;
int j = 0;

void f(int& a, int b)
{
++a;
++b;
++i;
}

int main()
{
int a = 10;
int b = 12;
int j = 100;

f(a, b);
cout << setw(10) << a << setw(10) << b
<< setw(10) << i << setw(10) << j << endl;
f(i, j);
cout << setw(10) << a << setw(10) << b
<< setw(10) << i << setw(10) << j << endl;

return 0;
}
```
4. Recursion: no recursion.
1. char
2. short
3. int
4. long
5. signed, unsigned.
6. float (6, 38).
7. double (19, 4,932).
8. long double
6. Arithmetic anomalies:
1. Overflow.
2. Underflow.
3. Representational.
4. Cancellation.
7. Arrays:
1. Terminology, numbering.
2. Declaring.
3. Initializing: numeric, char, strings (2 ways).
4. Using.
5. Parameter passing: one element, entire array (size parameter).
8. Disk I/O:
1. fstream.h
2. ifstream, ofstream
3. open()
4. fail()
5. eof()
6. close()
7. get()
8. getline()
9. Character data and strings:
1. ASCII, EBCDIC
2. Collating sequence (Professor Levish???).
3. ctype.h
4. tolower(), toupper(), etc.
5. isupper(), islower(), etc.
6. Requirements for a string.

Thomas P. Kelliher
Thu May 16 18:36:35 EDT 1996
Tom Kelliher