Monday is a holiday! Our next class will be Wednesday!
Here are a few comments and corrections about last Thursday's lab and homework.
While I was discussing the lab, I talked about how, if a program wants to use a function, it must "define" or "explain" the rules for using that function with
float fran ( float a, float b, int *seed );which is a copy of the first line of the fran() function.
I mentioned that when your program actually uses fran(), you have to give it the input quantities that we called a, b, and seed, and that for a and b, you could choose either to declare variables, give them values, and then pass those names, or you could actually just put the numeric values. Because the value for b was 15, some people tried to do the second option with a call like this:
x = fran ( 12.5, 15, &seed );but this gives crazy results. That's because C is expecting a float value as the second input, but what you gave it was 15, which counts as an integer. Instead of complaining (which it should do!) it figures out the binary interpretation of the integer 15, and gives that to fran, which looks at the same binary numbers and reads them as a float, which gives a crazy result. This is why I prefer to pass variables rather than the actual values. I'll talk about this more when we get to officially look at functions!
In the discussion of the homework, I explained that the ratio of hits to total tries was approximately equal to the ratio of the areas of the circle to the square ( true ) but then I wrote the following formula:
estimate for area of circle = ( hits / total ) / ( area square )That's wrong, and the formula should be
estimate for area of circle = ( hits / total ) * ( area square )instead.