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
2 1502
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
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. :) -
-
#include <stdio.h>
-
#include <conio.h>
-
#include<math.h>
-
using namespace std;
-
-
float distance(float,float,float,float);
-
void main()
-
{
-
float calculate,input1,input2,input3,input4;
-
//take user inputs here,
-
calculate=distance(input1,input2,input3,input4);
-
cout<<calculate<<endl;
-
return 0;
-
}
-
-
float distance(float input1,float input2,float input3,float input4)
-
{
-
float result,diff1,diff2,addition;
-
diff1=input3-input1;
-
diff2=input4-input2;
-
diff1=diff1*diff1
-
diff2=diff2*diff2;
-
addition=diff1+diff2;
-
result=sqrt(addition);
-
return result;
-
}
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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 :...
|
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...
|
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...
|
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...
|
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...
|
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>...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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,...
|
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,...
|
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...
|
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...
|
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...
| | |