Skip to content

Instantly share code, notes, and snippets.

@batmantec
Created February 16, 2016 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batmantec/03e91eda0605eef62746 to your computer and use it in GitHub Desktop.
Save batmantec/03e91eda0605eef62746 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cmath>
using namespace std;
float h (float x1, float x2, float y1, float y2){
float a, b, ans;
a=x2-x1;
b=y2-y1;
ans=sqrt((pow(2.0,a))+(pow(2.0,b)));
return ans;
}
int main (){
float x1, x2, y1, y2, a, b, ans;
cout << "This program calculates the distance between to points"<<endl;
cout << "Please give me x1: ";
cin >> x1;
cout << "Please give me x2: ";
cin >> x2;
cout << "Please give me y1: ";
cin >> y1;
cout << "Please give me y2: ";
cin >> y2;
ans=h(x1,x2,y1,y2);
cout << "The answare is: "<<ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment