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

what's wrong with my code!!!?

momotaro
357 100+
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!
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <math.h>
  3. double d;
  4. double distance (double x_1, double x_2, double y_1, double y_2); 
  5. main()
  6. {
  7.     double x_1, x_2, y_1, y_2;
  8.     printf("Enter the coordination of your first point:");
  9.     scanf("%lf %lf", &x_1, &y_1);
  10.     printf("Enter the coordination of your second point:");
  11.     scanf("%lf %lf", &x_2, &y_2);
  12.     printf("The distance is: %f", d);
  13.     scanf("%f", &d);
  14. }
  15. // The definition of the function distance.
  16. double distance (double x_1, double x_2, double y_1, double y_2)
  17. {
  18.         d=sqrt(pow(x_2-x_1, 2)+pow(y_2-y_1, 2));
  19.         return (d);
  20. }
Nov 6 '06 #1
1 1324
horace1
1,510 Expert 1GB
you forgot to call the distance() function, code should be
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <math.h>
  3. double d;
  4. double distance (double x_1, double x_2, double y_1, double y_2); 
  5. main()
  6. {
  7.     double x_1, x_2, y_1, y_2;
  8.     printf("Enter the coordination of your first point:");
  9.     scanf("%lf %lf", &x_1, &y_1);
  10.     printf("Enter the coordination of your second point:");
  11.     scanf("%lf %lf", &x_2, &y_2);
  12.     d=distance(x_1, x_2, y_1, y_2);               // ** missing
  13.     printf("The distance is: %f", d);
  14.     scanf("%f", &d);
  15. }
  16. // The definition of the function distance.
  17. double distance (double x_1, double x_2, double y_1, double y_2)
  18. {
  19.         d=sqrt(pow(x_2-x_1, 2)+pow(y_2-y_1, 2));
  20.         return (d);
  21. }
  22.  
  23.  
Nov 6 '06 #2

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

Similar topics

3
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."',...
4
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
5
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...
1
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....
3
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');"...
4
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...
1
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....
7
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...
5
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...
5
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...
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: 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$) { } ...
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
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...
0
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...
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
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,...

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.