|
|
|
|
|
|
|
The compiler does not complain at all. It generates code to coerce the int value to an unsigned int value. If you now print out the value of unsignedVar, you'll see a strange-looking positive integer. As we have pointed out before, unsigned types are most appropriate for advanced techniques that manipulate individual bits within memory cells. It's best to avoid using unsigned for ordinary numeric computations. |
|
|
|
|
|
|
|
|
Problem-Solving Case Study Finding the Area Under a Curve |
|
|
|
|
|
|
|
|
Problem: Find the area under the curve of the function X3 over an interval specified by the user. In other words, given a pair of floating point numbers, find the area under the graph of X3 between those two numbers (see Figure 10-6). |
|
|
|
|
|
|
|
|
Input: Two floating point numbers specifying the interval over which to find the area, and an integer number of intervals to use in approximating the area. |
|
|
|
|
|
|
|
|
Figure 10-6
Area Under Graph of X3 Between 0 and 3 |
|
|
|
|
|