Here's the code.
int a;
int pi = 3.14;
int area;
int main()
{
cout << "Input the radius of the circle ";
cin >> a;
a *= a *= pi >> area;
cout << "The area is " << area;
}
The definite integral can be used to calculate net signed area, which is the area above the x-axis less the area below the x-axis. Net signed area can be positive, negative, or zero.
If the function calculates change in position with respect to time (velocity), then if the value of the integral is 0 it means the displacement is 0, i.e you are back to your starting point, either because you stayed there the whole time (V=0), or you moved but then turned around and came back.
Finally, unlike the area under a curve that we looked at in the previous chapter the area between two curves will always be positive. If we get a negative number or zero we can be sure that we've made a mistake somewhere and will need to go back and find it.
The area under a curve between two points is found out by doing a definite integral between the two points. To find the area under the curve y = f(x) between x = a & x = b, integrate y = f(x) between the limits of a and b. This area can be calculated using integration with given limits.
The >>
operator when used with numbers is right shift, not assignment. You want something like
area = a * a * pi;
Update
You also need to use a floating point type or your answer won't be what you expect.
float a;
float pi = 3.14f;
float area;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With