# A C Solution

We now know enough about simulating the heat flow problem and enough about arrays in C to sketch the implementation of a program that can simulate heat flow. You will be fleshing out this program as your homework for this lesson.

Our program will conduct the simulation by dividing the rod, which is assumed to have a length of 2, into up to 20 segments. It will:

• Prompt the user for the initial conditions: the temperatures of the two heat sources, the initial temperature of the rod, the number of segments into which the rod should be divided, the number of time units to simulate, and the value of the constant C.
• Print out a histogram showing the initial temperature of each segment.
• For each of the time units in the simulation,

• Calculate and record the temperature of each segment after one more time unit has passed.
• Print out a histogram showing the new temperature of each segment.

When the program finishes running, then, we will have a record of how the temperature of the rod varies with time.

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