질문드립니다~~~~

#include stdio.h
#include math.h
#include conio.h

float funct(float);
void main(void)
{inti,num;
floatxl,xh,f_out,h,integ;
printf(\nEnter the lower value of x-domain : );
scanf(%f,&xl);
while(1)
{printf(\nEnter the higher value of x-domain : );
scanf(%f,&xh);
if(xhxl)break;
else
{printf(\nRetype!!!!);
continue;
}
}
while(1)
{printf(\nEnter the number of division : );
scanf(%d,&num);
if(num0)break;
else
{printf(\nRetype!!!!);
continue;
}
}
h = (xh-xl)/(float)num;
integ = 0.0;
for(i=1;inum;i++)
{f_out = funct(xl+(float)i*h);
integ += h*f_out;
}
integ += h*(funct(xl)+funct(xh))/2.;
printf(\nThe integrated region = %f\n,integ);
getch();
}
float funct(float x)
{floatout;
out = sin(x);
return(out);
}
네 이 프로그램은 사인엑스라는 함수를 적분하는건데요.

적분구간을 세밀하게 나눌수록 적분값이 더 정확하게 나오는 프로그램인데...

적분구간 나누는것을.. 저렇게 입력받지 말고,

무한루프를 돌아서 그전 적분값과의 차이가 0.0001이하라면.. 그때의 그 값으로 적분값을 구하는 방식의

프로그램으로 바꾸어야 하는데요 ㅠ_ㅠ

감이 안와서요 ㅠ_ㅠ 방법은 맞는지;;;; 가르쳐주실분 급구합니다 ㅠ_ㅠ

댓글 0

아직 댓글이 없습니다.

프로그램 개발일반 다른 글

목록