473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

thanks in advance:

12
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
Nov 5 '06 #1
0 943

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: solartimba | last post by:
I am using the advance() auxiliary STL iterator function to move a map iter forward, but I read that there is no check to keep the iter from pointing past the end of the map. How is this problem...
5
by: Gernot Frisch | last post by:
Hi, what doi I get when I advance too much? std::list<int> L; L.push_back(4); std::list<int>::iterator it = L.begin; std::advance(it, 3); for(; it!=L.end(); ++it) {
3
by: williamc | last post by:
Somebody asked me if it would be possible to add auto-advance to a web form where there are a lot of repetitive 5 character fields. I took a look around the web and found a script, which appears to...
8
by: swilson513 | last post by:
In Access97 I was able to have an advance filter on a form that had a Like statement so when you applied the filter EACH time it would asked for the criteria. In 2000 the same filter doesn't asked...
2
by: ratedr1 | last post by:
I am currently trying to label rings (jewelry). They make specialized tags (shaped like a butterfly, barbell, dumbell, etc) for this purpose, the label goes through the ring, and then the ends...
2
by: Greier Matthias | last post by:
Hi! I've got a sport-database for my students with name - class - teacher - year of birth - 60meter-runningtime - 100meter - longjump - ...(and some other disciplines) The whole program...
1
by: Netserver | last post by:
Hi in the display properties off the control panel, tab settings,advance button. Font size has two sizes, the default is small. when you create your form with this default size everything is fine...
5
by: A. Farber | last post by:
Hello, I call readv() and writev() in several spots of a program which I run under Linux, OpenBSD and Cygwin. Since it always the same way (check the return value; then check errno and retry if...
10
by: dolphin | last post by:
Hi All. I have learn the C++ for sometime. Now I want to learn some advance topics. Can someone recommend some advance topic?
4
by: sarika | last post by:
Which group should i join for learning advance ajax plz help
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.