#include <stdio.h>

void main()
    {
        float p,q,w,l,b,h,b1,h1,i,limit,v,m,ss,bs,vmax,mmax,ssmax,bsmax,r1,c,bb,x;

        printf("Enter the value of distributed load=");
        scanf("%f",&w);
        printf("Enter the value of distance=");
        scanf("%f",&x);
        printf("Enter the value of point load=");
        scanf("%f",&p);
        printf("Enter the value of length l=\n");
        scanf("%f",&l);
        printf("Enter the value b h=\n");
        scanf("%f%f",&b,&h);
        printf("Enter the value b1 h1=\n");
        scanf("%f%f",&b1,&h1);

        r1=((w*l*0.5)+(p*0.5));
        printf("Reaction =%f",r1);

        q=((b*h*0.5)*(h*0.25))-((b1*h1*0.5)*(h1*0.25));
        c=h/2;
        i=((b*h*h*h)/12)-((b1*h1*h1*h1)/12);
        limit=l/2;
        bb=b-b1;

    for(x=0;x<limit;x=x+(l/10))
    {
        v=r1-(w*x);
        m=(r1*x)-(w*x*x*0.5);
        ss=(v*q)/(i*bb);
        bs=(m*c)/i;
        printf("\nDistance=%f,shear=%f,moment=%f,shear stress=%f,bending stress=%f",x,v,m,ss,bs);
    }

    for(x=limit;x<=l;x=x+(l/10))
    {
        v=r1-(w*x)-p;
        m=(r1*x)-(w*x*x*0.5)-(p*(x-(l*0.5)));
        ss=(v*q)/(i*bb);
        bs=(m*c)/i;
        printf("\n Distance=%f,shear=%f,moment=%f,shear stress=%f,bending stress=%f",x,v,m,ss,bs);
    }

    vmax=r1;
    mmax=(r1*l*0.5)-(w*l*l*0.5*0.5*0.5);
    ssmax=(vmax*q)/(i*bb);
    bsmax=(mmax*c)/i;
    
    printf("\nMax shear stress=%f,Max bending stress=%f",ssmax,bsmax);
}