this is my programme, i try it but there is a mistake, can you help to find it :the request is above
#include<stdio.h>
#include<math.h>
#define SENTINEL 'Q'
int menu();
int distance(int);
void prompt();
int main() {
char choice;
int x1,x2,y1,y2,d,m;
do {
choice = menu();
switch(choice) {
case '1':
printf("\n Enter the x1 :");
scanf(" %d" ,&x1);
printf("\n Enter the x2 : ");
scanf(" %d" , &x2);
printf("\n Enter the y1 :");
scanf(" %d", &y1);
printf("\n Enter the y2 :");
scanf(" %d", &y2);
printf("\n the distance is: %d", distance(m));
break;
case 'Q':
break;
default:
printf("\n INVALID INPUT");
}
} while(choice !=SENTINEL);
printf("\n Bye :-)");
scanf(" %lf");
}
int menu() {
char choice;
printf("\n -----------------------------");
printf("\n ******** Menu ********** ");
printf("\n -----------------------------");
printf("\n ** 1 ** distance ");
printf("\n ** Q ** Quit ");
printf("\n ----------------------------");
printf("\n - choice: ");
scanf(" %c", &choice);
return(choice);
}
int distance(m) {
int x1,x2,y1,y2,d;
if (x1<x2 && y1<y2){
d=((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1));
m=sqrt(d);
}
else if (x1<x2 && y2<y1){
d=((x2-x1)*(x2-x1))+((y1-y2)*(y1-y2));
m=sqrt(d);
}
else if (x2<x1 && y2<y1){
d=((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2));
m=sqrt(d);
}
else if (x2<x1 && y1<y2){
d=((x1-x2)*(x1-x2))+((y2-y1)*(y2-y1));
m=sqrt(d);
}
return(m);
}
Write a function “distance” that takes four arguments corresponding to the Cartesian Coordinates of two points (x1, y1) and (x2, y2), and returns the distance between the two points.
- Call your function from a main program (write a complete program)
- Your program should execute iteratively till a Sentinel value is types