Skip to content

Instantly share code, notes, and snippets.

@JHeld07
Created April 23, 2015 02:49
Show Gist options
  • Save JHeld07/3a362f0098287293d592 to your computer and use it in GitHub Desktop.
Save JHeld07/3a362f0098287293d592 to your computer and use it in GitHub Desktop.
#include <conio.h>
#include <stdio.h>
#include <math.h>
// Josh Held 4/22/15
//Design 1
/*
struct distance{
int ft;
int in;}d1, d2, result;
main(){
int x;
printf("Enter a distance in ft and in: ");
scanf(" %d %d", &d1.ft, &d1.in);
printf("Enter a distance in ft and in: ");
scanf(" %d %d", &d2.ft, &d2.in);
result.ft=((d1.ft+d2.ft)*12);
result.in=(d1.in+d2.in);
x=(result.ft+result.in);
result.in=(x%12);
result.ft=(x/12);
printf("Distance ft: %d in: %d", result.ft, result.in);
while(!kbhit()){}
}
*/
//Design 5
/*
typedef struct{
float x;
float y;}point;
void pointshow(point otherpoint);
main(){
point test = {.25, .75};
pointshow(test);
while(!kbhit()){}
}
void pointshow(point otherpoint){
printf(" x=%f y=%f",otherpoint.x, otherpoint.y);
}
*/
//Research 6
typedef struct{
float x;
float y;}point;
float euclideandistance(point one, point two);
main(){
point p1, p2;
float distance, result;
printf("Enter the cordinates of the first number: ");
scanf(" %f %f", &p1.x, &p1.y);
printf("Enter the cordinates of the second number: ");
scanf(" %f %f", &p2.x, &p2.y);
distance = euclideandistance(p1, p2);
printf(" The Euclidean Distance is %f", distance);
while(!kbhit()){}
}
float euclideandistance(point one, point two){
return(sqrt(pow(one.x-two.x,2.0)+pow(one.y-two.y,2.0)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment