発展2

2017/12/05

#include <stdio.h>

int main()
{
    int a,b,N,i;
    printf("Please input three integers for an interval and a resolution : ");
    scanf("%d%d%d",&a,&b,&N);
    double ans = (double)a*a,sa = ( (double)(b-a) / (double)N ),nau = (double)a;
    for(i = 1;i <= N;i++){
        nau += sa;
        ans += nau*nau*sa;
    }
    printf("Definite integral from %d to %d of x^2 : %f
",a,b,ans);
    return 0;
}