I want to get roots of many double type variables (with some operators in it) in a line of C.
Example: In normal mathematics, √(b-a)2+(d-c)2
I had tried this in different ways, like
#include <math.h>
#include <stdio.h>
int main() {
int i, Test;
double a, b, c, d, e, f, g, h, j, num, root;
scanf("%d",&Test);
for(i=1; i <= Test; i++) {
scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
e = b - a;
f = d - c;
g = e * e;
h = f * f;
j = g + h;
root = sqrt(j);
printf("Case %d: %.4lf\n",i,root);
}
return 0;
}
}
But, I don't get the correct answer.
Description Sample Input Output
Please anyone help me with this.