Weddle ' s Rule in C

 #include<stdio.h>
    float f(float x)
    {
        return (1/(1+x));
    }
    main()
    {
        int i,n;
        float a,b,h,s=0,x,y[100],s1=0,s2=0,s3=0,s4=0,t;
        printf("\n\t\t----~~~~ Crazy Coder---- TechApurba----~~~~");
        printf("\n\n\t : weddle rule : \n");
        printf("\nEnter the lower limit : ");
        scanf("%f",&a);
        printf("\nEnter the upper limit : ");
        scanf("%f",&b);
        printf("\nEnter the number of sub-intervals : ");
        scanf("%d",&n);
        h=(b-a)/n;
        x=a;
        for(i=0;i<=n;i++)
        {
            y[i]=f(x);
            x=x+h;
        }
        for(i=0;i<=n-6;i+=6)
        {
            s1=s1+y[i+2]+y[i+4];
            s2=s2+y[i+1]+y[i+5];
            s3=s3+y[i+3];
        }
        for(i=0;i<=n-12;i+=6)
            s4=s4+y[i+6];
        s=(3*h/10)*(y[0]+y[n]+s1+5*s2+6*s3+2*s4);
        printf("\nThe result of the equation (1/(1+x)) is:  %f\n\n",s);
    }




For Other Programs Visit The WebSite:-   https://www.techapurba.com/

Follow Me On Social Media :-

Instagram link :- https://www.instagram.com/apurba_khanra/
INSTA photography page :- https://www.instagram.com/photo_mania_hub/
Twitter link : - https://twitter.com/ApurbaKhanra199
Facebook page link (Crazy Coders) :-https://www.facebook.com/codercrazy/?modal=admin_todo_tour

Insta photography link :- https://www.instagram.com/photo_mania_hub/

Facebook link :- https://www.facebook.com/profile.php?id=100009747586288
FB photography page :-  https://www.facebook.com/photomaniahub/?modal=admin_todo_tour

For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/

Post a Comment

0 Comments