Answer

Were you surprised? You probably expected the correct average to be printed out, but once again it wasn't. This time the correct average was indeed computed, but it was assigned to the variable K before it was printed. What happens when a REAL value is assigned to an INTEGER variable? The real value is truncated (i.e. the decimal portion is discarded). This is similar to what happened when you tried reading a REAL value as an INTEGER.

Return to lesson.



Hamlet Project
hamlet@cs.utah.edu