473,326 Members | 2,147 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,326 software developers and data experts.

compiler error

Hi, i am new to programming and am having a little problem in running my program on Dev-C++.this is the codes i have used.
i have also got 2 errors: invalid function declaration [build Error] 1


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<math.h>
  3. int distance
  4.  
  5. {
  6.  
  7.     int float x1 , x2 ,y1, y2 ,d;
  8.     system ("pause")
  9.     printf("\n\t distance formula\t(please enter 0 for all coordinate to quit)");
  10.     while (1==1);
  11.     {
  12.         printf("\nfirst corner:");
  13.         printf("\n x:");
  14.         scanf("%f",&x1);
  15.         printf("Y");
  16.         scanf("%f",&Y1);
  17.  
  18.         printf("\nsecond corner:");
  19.         printf("\n x:");
  20.         scanf("%f,&x2");
  21.         printf("Y:");
  22.         scanf("%f",&Y2);
  23.         if (x1==0,x2==0,Y1==0,Y2==0);
  24.         {
  25.             return 0;
  26.         }
  27.             D=sqrt((x2-x1)*(x2-x1)+(Y2-Y1)*(Y2-Y1));
  28.             prinf("\n distance = %f",d);
  29.                 printf("\n.");
  30.     }
  31. }
  32.  
Can anyone please try to run this program and help me edit the code ASAP.thanks
Aug 9 '07 #1
8 1156
JosAH
11,448 Expert 8TB
Hi, i am new to programming and am having a little problem in running my program on Dev-C++.this is the codes i have used.
i have also got 2 errors: invalid function declaration [build Error] 1


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<math.h>
  3. int distance
  4.  
  5. {
  6.  
  7.     int float x1 , x2 ,y1, y2 ,d;
  8. ... 
  9.  
Function declarations and definitions need parameter lists, even when they're
empty, so your function definition should look similar to this:

Expand|Select|Wrap|Line Numbers
  1. int distance() // <--- empty parameter list here
  2.  
  3. {
  4. ...
  5.  
kind regards,

Jos
Aug 9 '07 #2
Function declarations and definitions need parameter lists, even when they're
empty, so your function definition should look similar to this:

Expand|Select|Wrap|Line Numbers
  1. int distance() // <--- empty parameter list here
  2.  
  3. {
  4. ...
  5.  
kind regards,

Jos


well thanks for your help...I did appreciate your posted solution but am still finding hard to run the program.

[code=cpp]
int distance() // <--- empty parameter list here
........

what do you mean i should empty my parameter list?
could you please specify into detail on how i should go about it. (well detailed).


Thank you.
Aug 9 '07 #3
JosAH
11,448 Expert 8TB
well thanks for your help...I did appreciate your posted solution but am still finding hard to run the program.

Expand|Select|Wrap|Line Numbers
  1. int distance() // <--- empty parameter list here
  2. ........
  3.  
what do you mean i should empty my parameter list?
could you please specify into detail on how i should go about it. (well detailed).


Thank you.
Everything between the parentheses are the parameters; your function doesn't
take any parameters (as far as I can see), so you should have an empty parameter
list as I wrote in the comment. The // comment wasn't an order, it was just a
clarification of what you saw there: an empty parameter list.

kind regards,

Jos
Aug 10 '07 #4
svlsr2000
181 Expert 100+
[quote=kingsleyterrace]Hi, i am new to programming and am having a little problem in running my program on Dev-C++.this is the codes i have used.
i have also got 2 errors: invalid function declaration [build Error] 1


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<math.h>
  3. int distance
  4.  
  5. {
  6.  
  7. int float x1 , x2 ,y1, y2 ,d;
  8. system ("pause")
  9. ....
  10. }
  11.  
You need to terminate function or sytem calls wirh " ; " as well. This would again result in compiler error
Aug 10 '07 #5
FishVal
2,653 Expert 2GB
Hi, i am new to programming and am having a little problem in running my program on Dev-C++.this is the codes i have used.
i have also got 2 errors: invalid function declaration [build Error] 1


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<math.h>
  3. int distance
  4.  
  5. {
  6.  
  7.                 .....................
  8.     while (1==1);                   // remove ";" here
  9.     {
  10.       ..............
  11.                         // remove ";" here and replace "," with ";"    
  12.                         if (x1==0,x2==0,Y1==0,Y2==0);         {
  13.             return 0;
  14.         }
  15.             ....................    }
  16. }
  17.  
Can anyone please try to run this program and help me edit the code ASAP.thanks
Many syntax errors.

Additionally to the previous post you need to remove ";" from "while" and "if" as they treated as end of instruction, the rest in {} will be treated as separate code.
You need to replace "," with ";" in "if" statement.
Aug 12 '07 #6
thank you , but that does not seem to be the problem because i have done exactly what i was asked to do but it does not work and i am still getting the same error . i will really appreciate if some one can run the original program and correct it for me please ASAP.
Aug 15 '07 #7
ilikepython
844 Expert 512MB
You need to replace "," with ";" in "if" statement.
Semicolon? I think the O/P needs to put and's "&&". or or's "||".
Expand|Select|Wrap|Line Numbers
  1. if ( x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0)
  2. {}
  3. // or....
  4. if (x1 == 0 || x2 == 0 || y1 == 0 || y2 == 0)
  5. {}
  6.  
Aug 15 '07 #8
ilikepython
844 Expert 512MB
thank you , but that does not seem to be the problem because i have done exactly what i was asked to do but it does not work and i am still getting the same error . i will really appreciate if some one can run the original program and correct it for me please ASAP.
You have used some variables as they are capitals but you declared them lowercase. Remember, C++ is case-sensetive. For example, in your if you had:
Expand|Select|Wrap|Line Numbers
  1. if (...... Y1 == 0 && Y2 == 0){}
  2.  
  3. // should be ....
  4.  
  5. if (...... y1 == 0 && y2 == 0){}
  6.  
Aug 15 '07 #9

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

Similar topics

6
by: paul calvert | last post by:
I hope somewhere here has encountered and solved a similar problem in the past. 1) on a new Win2000 PC: installed Visual C++ 6.0 download & install single file Service Pack 5.0 2) try to...
2
by: Mike Fisher | last post by:
I'm seeing an error when I try to run/debug a web service. Although it doesn't happen every time, it does occur more than half of the times I hit F5. It appears to be returned by the the JIT...
10
by: Bjorn | last post by:
I'm using interfaces in C++ by declaring classes with only pure virtual methods. If then someone wants to implement the interface they needs to inherit from the class. If the implementing class...
2
by: Mary | last post by:
Hello, I am having a problem with the cl compiler. I have written a C class (RegConnect.c) which uses Win32 API functions such as RegOpenKey, RegCloseKey etc. Initially when I was trying to...
0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
1
by: Ayende Rahien | last post by:
reparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12): likely culprit is 'BIND'. An internal...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
4
by: David Sworder | last post by:
Consider the following line of code (it's not important what it does): resp.DocItem=Relations.SelectDocItems_BySearchString(req.SearchPhrase); It turns out that this line is in error. The...
6
by: David Lack | last post by:
Hi, I recently installed a 60-day trial of .NET 2003 on my development system. I made tests with previous personal projects (which compiled ok with VC6) and some open source files, and keep...
27
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.