#include #include float valueFx(float x); float valueGx(float x); float areaBetweenCurve(int a,int b,float deltaX); int main() { int a = -2,b=2; //printf("Enter the boundary values : a,b "); //scanf("%d,%d",&a,&b); float delX = 0.001; printf("Area of curve : %f \n",areaBetweenCurve(a,b,delX)); printf("Area of broken curve : %f \n", areaBetweenCurve(a,0,delX) + areaBetweenCurve(0,b,delX) ); return 0; } float valueFx(float x) { return -1 * x* x + 3*x; } float valueGx(float x) { return 2*x*x*x - x*x - 5*x; } float areaBetweenCurve(int a,int b,float deltaX) { float lowX = a,highX = a + deltaX,area = 0.0; while(highX <= b) { //printf("lowX : %f HighX : %f \n",lowX,highX); if(lowX < 0 && highX > 0) { //printf("HOw : lowX : %f HighX : %f \n",lowX,highX); area += (0 - lowX) * fabs(valueFx(lowX) - valueGx(lowX)) + (highX - 0) * fabs(valueFx(1) - valueGx(1)); } area += (highX-lowX)*fabs(valueFx(lowX) - valueGx(lowX)); lowX = highX; highX = highX + deltaX; } if(lowX < b && highX > b) { area += (b-lowX)*fabs(valueFx(lowX) - valueGx(lowX) ); } return area; }