[C] Struct distance example
/*------------------------------------------------------------------------------------------
@ Pratice C laguage
Author : SAM
Created : 28-03-2017
Modified : 28-03-2017
Language/ver : C in MSVS2015
Description : Practice : distance1.c
------------------------------------------------------------------------------------------*/
#include <stdio.h>
#include <math.h>
struct point {
int x;
int y;
};
int main(void) {
struct point p1, p2;
double distance;
fputs("Input first x, y ", stdout);
scanf_s("%d %d", &p1.x, &p1.y);
fputs("Input first x, y ", stdout);
scanf_s("%d %d", &p2.x, &p2.y);
/*Calculate distance between p1 and p2*/
distance = sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
printf("Distance between two points is %f\n", distance);
return 0;
}