am unsing a fuction called distance to compute the distance between two points
but my program seems to not take my inputs because it returs always 0 whatever are the values that i put...plz help!
-
#include <stdio.h>
-
#include <math.h>
-
double d;
-
double distance (double x_1, double x_2, double y_1, double y_2);
-
main()
-
{
-
double x_1, x_2, y_1, y_2;
-
printf("Enter the coordination of your first point:");
-
scanf("%lf %lf", &x_1, &y_1);
-
printf("Enter the coordination of your second point:");
-
scanf("%lf %lf", &x_2, &y_2);
-
printf("The distance is: %f", d);
-
scanf("%f", &d);
-
}
-
// The definition of the function distance.
-
double distance (double x_1, double x_2, double y_1, double y_2)
-
{
-
d=sqrt(pow(x_2-x_1, 2)+pow(y_2-y_1, 2));
-
return (d);
-
}
1 1324
you forgot to call the distance() function, code should be -
#include <stdio.h>
-
#include <math.h>
-
double d;
-
double distance (double x_1, double x_2, double y_1, double y_2);
-
main()
-
{
-
double x_1, x_2, y_1, y_2;
-
printf("Enter the coordination of your first point:");
-
scanf("%lf %lf", &x_1, &y_1);
-
printf("Enter the coordination of your second point:");
-
scanf("%lf %lf", &x_2, &y_2);
-
d=distance(x_1, x_2, y_1, y_2); // ** missing
-
printf("The distance is: %f", d);
-
scanf("%f", &d);
-
}
-
// The definition of the function distance.
-
double distance (double x_1, double x_2, double y_1, double y_2)
-
{
-
d=sqrt(pow(x_2-x_1, 2)+pow(y_2-y_1, 2));
-
return (d);
-
}
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris Geerdink |
last post by:
combo with PHP. what is wrong with the Javascript?
else
{
include("mysql.php");
$query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES
('".$_POST."', '".$_POST."',...
|
by: asdf |
last post by:
Hello!
Can someone tell me whats wrong with this piece of code:
Option Compare Database
Option Explicit
Sub retrieve()
Dim rst As ADODB.Recordset
Dim i As Integer
|
by: Alexandre Martins |
last post by:
Provider=Microsoft.Jet.OLEDB.4.0;UserId=Admin;Password=teste;Data
Source=C:\Inetpub\wwwroot\inktoner\dados\db_inktoner.mdb;Persist Security
Info=True
I can't connect in my database !
whats...
|
by: aa |
last post by:
When I am reading from local disk (d:), everithing is OK, but then I am
reading from map disk I am geting the this error. Whats wrong. Thanks
Server Error in '/Extra' Application....
|
by: mahsa |
last post by:
Hi do you know whats wrong with this code?
<asp:HyperLink id="HLink_Help" runat="server" NavigateUrl='<%# "javascript:window.open('comments.aspx?id=1,width=500,height=600, scrollBars=yes');"...
|
by: blah |
last post by:
Hello everyone, Ive been trying to get my application to "click" on a
button in another application using SendMessage, Ive gotten this far
but Im not sure whats wrong with this code, here is the...
|
by: '~=_Slawek_=~' |
last post by:
$DOW = (jddayofweek(unixtojd(mktime(1, 1, 1, $month, $day, $year)))+6)%7;
$DOW= (jddayofweek(juliantojd($month, $day, $year))+6)%7;
The results are supposed to be the same, but they are not....
|
by: Mike Barnard |
last post by:
It's a simple test... VERY SIMPLE. But...
In an external stlyesheet some attributes don't show. With the same
styles cut and pasted to the test internally it works as expected.
Anyone tell...
|
by: islayer |
last post by:
can someone tell me what is wrong with the bold code? i am just learning perl. the program should create a perl file with a random name (5 letters, followed by a number), but the name is always just...
|
by: hiqu |
last post by:
This issue is driving me nuts and not able to figure out whats wrong.
I've this code in my firefox extension. Firefox always hangs and
reports the script is busy.
if I introduce a break...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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: 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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
| |