#include <stdio.h> #include <stdlib.h> #include <math.h> struct Point { int x, y; }; double getDistance(struct Point a, struct Point b) { double distance; distance = sqrt((a.x - b.x) * (a.x - b.x) + (a.y-b.y) *(a.y-b.y)); return distance; } int main() { struct Point a, b; printf("Enter coordinate of point a: "); scanf("%d %d", &a.x, &a.y); printf("Enter coordinate of point b: "); scanf("%d %d", &b.x, &b.y); printf("Distance between a and b: %lf\n", getDistance(a, b)); return 0; }
This Blog is All about various C & C++ programs using Graphics.h header files. The programs are Compiled using Turbo C++ & C .Here i will be posting source codes of programs in C or C++ or Computer Graphics
Calculate Distance of Two Points using C Structure
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment