Data Structures

We will need to use two arrays to keep track of temperatures in our program.

float oldtemps[20];
float newtemps[20];

When we are ready to simulate the next tick of simulated time, oldtemps will hold the current temperature of each segment. As we calculate the new temperatures for each segment, we will store those temperatures into newtemps. After we have calculated each of the new temperatures, we will copy them back into oldtemps in preparation for the next tick of the simulated clock.

Why do we need two arrays? As we calculate new temperatures, why can't we simply store them back into oldtemps?

Click here for the answer

Notice that we arrange for each array to be large enough to represent up to 20 segments. This does not mean that we will use every entry in each array. If the user asks to user fewer than 20 segments, we will only use a portion of each array.

Eric N. Eide
Hamlet Project
Department of Computer Science
University of Utah