Logic:

Area=1/2*(a+c)√(b²-((b²-d²+(a-c)²)/(2(a-c))²)

<Source Code>

#include<stdio.h>

#include<math.h>

#define min(a,b) a<b?a:b

#define PI acos(-1)

int main()

{int t,i;

double a,b,c,d,m,tem=0,x,h,angle,sqa;

scanf(“%d”,&t);

for(i=1;i<=t;i++){

scanf(“%lf %lf %lf %lf”,&a,&b,&c,&d);

if(a>c)

{

c=min(a,c);

}

x=(a-c);

sqa=b*b-d*d+x*x;

sqa=(sqa/(2*x));

sqa=sqa*sqa;

sqa=sqrt(b*b-sqa);

printf(“Case %d: %.7lf\n”,i,(sqa*(a+c)/2));

}

}

Advertisements