#include<stdio.h>
#include<math.h>

int main()
{
    float r1,r2,w1,w2,s,m,x;

    printf("Enter 1st distributed load= ");
    scanf("%f",&w1);
    printf("Enter 2nd distributed load= ");
    scanf("%f",&w2);
    printf("Enter the value of distance= ");
    scanf("%f",&x);

    r1=(7.5*w1)+(2.5*w2);
    r2=(7.5*w2)+(2.5*w1);
    printf("\nReaction at point A,r1=%f",r1);
    printf("\nReaction at point B,r2=%f",r2);

    if( x>=0 && x<=10 )
    {
        s=r1-(w1*x);
        m=(r1*x)-(w1*x*x*0.5);
        printf("\n\nShear force at %f from left is=%f",x,s);
        printf("\nBending moment at %f from left is=%f",x,m);
    }

    else if(x>=10 && x<=20)
    {
        s=r1-(w1*10)-(w2*(x-10));
        m=(r1*x)-(w1*(x-5)*10)-(w2*(x-10)*(x-10)*0.5);
        printf("\n\nShear force at %f from left is=%f",x,s);
        printf("\nBending moment  at %f from left is=%f",x,m);
    }
    
    else
    {
        printf("\n\nEnter a valid value of x");
    }
}
