473,394 Members | 1,759 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,394 software developers and data experts.

need your help, i'm waiting

12
I'm supposed to :
1. 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

2. Write a function LCD (Least common divisor) that takes as input three integers, and returns the least common divisor of the three integers.
- 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
2 1502
vninja
40
returns the distance between the two points.
Write a function “distance” that takes four arguments

from these two parameters you know you have somthing like

returntype functionname(arg1, arg2, arg3, arg4)
{
since your finding the distance use the pythagorean therom from the difference of two of the four arguments
return ans of formula
}
and i have no idea what you mean by
- Your program should execute iteratively till a Sentinel value is types

and for the second part do repeat the first but instead of the pythagorean therom used a formula for finding the LCD.
Peace
Vninja
Nov 6 '06 #2
hey there,
the first function would be something like the following code. but keep one thing in mind that the user will have to enter some ending value to denote the end of input and this has to be mentioned while taking the input from the user. This is called the Sentinel value. :)

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include<math.h>
  5. using namespace std;
  6.  
  7. float distance(float,float,float,float);
  8. void main()
  9. {
  10. float calculate,input1,input2,input3,input4;
  11. //take user inputs here,
  12. calculate=distance(input1,input2,input3,input4);
  13. cout<<calculate<<endl;
  14. return 0;
  15. }
  16.  
  17. float distance(float input1,float input2,float input3,float input4)
  18. {
  19. float result,diff1,diff2,addition;
  20. diff1=input3-input1;
  21. diff2=input4-input2;
  22. diff1=diff1*diff1
  23. diff2=diff2*diff2;
  24. addition=diff1+diff2;
  25. result=sqrt(addition);
  26. return result;
  27. }
  28.  
I'm supposed to :
1. 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

2. Write a function LCD (Least common divisor) that takes as input three integers, and returns the least common divisor of the three integers.
- Call your function from a main program (write a complete program)
- Your program should execute iteratively till a Sentinel value is types
Nov 7 '06 #3

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

Similar topics

15
by: chahnaz.ourzikene | last post by:
Hi all, This is the first i post in this newsgroup, i hope my english is not too bad... Let's get straight to the point ! I have a little probleme using threads in my little training example :...
1
by: Brian Kitt | last post by:
I have a web app, where the user can enter search criteria, then click 'submit'. The search takes a few seconds. My customer wants a 'waiting' screen to come up with an animated Gif, then replace...
6
by: Lee Harr | last post by:
I have a database where I remove the schema public. When I try to use the createlang script, it fails like this ... >createdb foo CREATE DATABASE >psql foo -c "select version()" version...
5
by: coinjo | last post by:
Problem Statement One of the local banks is gearing up for a big advertising campaign and would like to see how long its customers are waiting for service by teller/service provider at drive-up...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
3
by: bangaw | last post by:
i'm currently using c++ on windowsXP, unistd.h doesnt work for windows what other substitute for it could i use to replace it Pls. Help me Pls pls the code goes as follows #include <stdio.h>...
1
by: matrix123456 | last post by:
Hi, How are you? I am student in college of technology and I have assigment in C++ programing and I can not solve it. please help me to program it in any language. The problem is: Three...
11
by: outofmymind | last post by:
Hi again, I've been solving these questions from past exam papers, and im not entirely confident about my answers. Im hoping that you guys can double check them for me. These are the...
3
by: anilreddypalla | last post by:
PROBLEM use Java to write and debug a small application that provide support for managing waiting lists.A waiting list consists of a NAME and an ordered list of PERSONS. Information about each...
1
by: Ajb181 | last post by:
hi all. i have a template class that i can not link. there is no problem when i add the method def's inside the header file but as soon as i move them out i get a link error where i define the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.