For some reason I can not get the if statements at the end to work. Atleast one of the if statements should work during each run of the program. Thanks in advance.
Code:
#include <stdio.h>
#include <math.h>
int main() {
int x1,x2,x3,y1,y2,y3,a1,a2,a3,a4,a5,a6;
double c12 = 0,c13 = 0,c23 = 0;
printf("What are the first x and y coordinates?\n");
scanf("%d %d", &x1, &y1);
printf("What are the second x and y coordinates?\n");
scanf("%d %d", &x2, &y2);
printf("What are the third x and y coordinates?\n");
scanf("%d %d", &x3, &y3);
c12 = (pow(x2 - x1,2) + pow(y2 - y1,2));
c12 = sqrt(c12);
printf("%.2lf\n", c12);
c13 = (pow(x3 - x1,2) + pow(y3 - y1,2));
c13 = sqrt(c13);
printf("%.2lf\n", c13);
c23 = (pow(x3 - x2,2) + pow(y3 - y2,2));
c23 = sqrt(c23);
printf("%.2lf\n", c23);
if (c12 + c13 == c23){
a1 = (x2 + x3)/2;
a2 = (y2 + y3)/2;
printf("(%d,%d) is the point in the middle", a1, a2);
}
if (c12 + c23 == c13){
a3 = (x1 + x3)/2;
a4 = (y1 + y3)/2;
printf("(%d,%d) is the point in the middle", a3, a4);
}
if (c23 + c13 == c12){
a5 = (x1 + x2)/2;
a6 = (y1 + y2)/2;
printf("(%d,%d) is the point in the middle", a5, a6);
}