#include #include float valueFx(float x); float lengthOfCurve(int a,int b,float deltaX); float r = 3.0; int main() { int a = -3,b=3; //printf("Enter the boundary values : a,b "); //scanf("%d,%d",&a,&b); float delX = 0.001; printf("Length of curve Actual: %f \n", 3.14159 * r); printf("Length of curve : %f \n",lengthOfCurve(a,b,delX)); return 0; } float valueFx(float x) { return sqrt( r*r - x*x); } float lengthOfCurve(int a,int b,float deltaX) { float lowX = a,highX = a + deltaX,length = 0.0; while(highX <= b) { float y2 = valueFx(highX); float y1 = valueFx(lowX); float y = y2-y1; float x2 = highX; float x1 = lowX; float x = x2-x1; length += sqrt ( y*y + x*x ); lowX = highX; highX = highX + deltaX; } if(lowX < b && highX > b) { float y2 = valueFx(b); float y1 = valueFx(lowX); float y = y2-y1; float x2 = b; float x1 = lowX; float x = x2-x1; length += sqrt ( y*y + x*x ); } return length; }