Sunday 1 January 2017

Program to read coordinate of two points and calculates the distance between them.

Share & Comment
CODE

#include <iostream.h>

#Include <stdlib.h>

#include <math.h>

Int main ()

{              system (“CLS”) ;

                Double distance, x1,y1,x2,y2 ;

                Cout << “Enter coordinates ( x y) of point 1 : “ ;

                Cin >> x1 >> y1 ;

                Cout << “Enter coordinates ( x y) of point 2 : “ ;

                Cin >> x2 >> y2 ;

                Distance = sqrt ( x1 – x2 ) * ( x2- x2 ) + (y1 – y2) * (y1- y2) ) ;

                Cout << “ The Distance between (“<<x1 <<”,”<<y1<<”) and (“<<x2<<”,”<<y2<<”) is : “ << distance << endl ;

Return 0 ;

Tags:

Written by

Hy, i am a Code Geek ! And like to eduate others.

0 comments:

Post a Comment

 
Copyright © C++ Programming | Designed by Templateism.com