# CSCI 255 Exam 2 Review

## Reference card

Three reference sheets will be available for you during the exam. The C reference card has much more than you need to know about C.

## Chapters covered

The second exam covers Chapters 1 to 4 and 6 of the textbook.

## Homework and assignments covered

The exam will concentrate on topics covered by homework and assignments. There will be some "review" problems from Homework 1, Homework 2, Assignment 1, and Exam 1. There will also be new problems similar to those of Homework 3, Assignment 3, Assignment 4, and Lab 7; but the exam problems will be much simpler.

## Pointers

Pointers are in C, but not in Java. A recent CSCI 373 exam asked students to draw the pointers and give the output generated by the following program. If you can do this, you have truly master pointers.

```  int a, b ;
int *p, *q ;
int v[2] ;
a = 10 ;
b = 20 ;
for (a = 0; a<2; ++a) {
v[a] = 30 + a*10 ;
}
printf("%d %d %d %d\n", a, b, v[0], v[1]) ;

p = &a ;
*p = b + 5 ;
v[0] = *p + 7 ;
printf("%d %d %d %d\n", a, b, v[0], v[1]) ;

p = &a ;
q = &b ;
*p = *q ;
*q = *p ;
printf("%d %d %d %d\n", a, b, v[0], v[1]) ;

q = &v[0] ;
p = q ;
b = *++q ;
a = ++*p ;
printf("%d %d %d %d\n", a, b, v[0], v[1]) ;

p = &v[0] ;
q = &v[1] ;
a = q-p ;
b = *q-*p ;
printf("%d %d %d %d\n", a, b, v[0], v[1]) ;
```