line 21 and line 22 are wrong.
First implement the function getmeters.
Indentation of the code is horrible. Write the getmeters function and repost code.
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
line 21: meters is a double, getmeters is a function. you can not assign a function to a double. But what you can do is assign the return value of the function to a double like this: meters=getmeters();
line 22: delete that line because it has wrong parameters (see function prototype on line 8) and doesn't do anything.
line 24: why are you printing the address ofmeters instead of its value ?
pay closer attention to the open and closing braces { and } -- they must match. For every { there must be a corresponding }. Don't be so careless in your coding.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>I dont know how to do that.
you don't know how to do what? I reformatted your code in another thread for free, I'm not going to do it again every time you post something. Go back to your other thread and see how I formatted it. Also read the information in the link that someone else posted. If you are not going to read the responses to the threads then there is not much we can do for you.
>>please give me something to go on
I did. learn to read the threads.
>>Our book is horrible
Maybe, but you have to read it.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>Sorry I didnt format right. I didnt know how
Here is a short tutorial on how to format your program. You should probably bookmark it so that you can refer to it often until you have it down in your head.
>>error LNK2019: unresolved external symbol "double __cdecl getmeters(void)" (?getmeters@@YANXZ) referenced in function _main
That error message is telling you that the compiler can not find a function named getmeters that does not have any parameters. You prototyped it ok on line 8 and called it on line 21, but nowhere did you actually write that function.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
using code tags here is pretty simple,
[code=c++]
// your code goes here
[/code]
And don't use tabs in your code because they will not look right when posted here even though they may look ok on your computer screen. Depending on what compiler you are using the compiler may have option to replace tabs with spaces. If not, then just hit the space bar on your keyboard instead of the tab key.
>>I dont know how to write the function for it, everything ive tried comes up with an error
post what you tried.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
your program is nearly complete -- all you have to really to is add that one function. Here is your program formatted correctly.
#include <iostream>
using std::cout;
using std::endl;
double y2m=1.09361329834;
double m2y=0.9144;
double getyards(int);
double getmeters();
int main ()
{
int i;
double meters;
for (i=5; i<=100; i=i+5)
{
double yards = getyards(i);
cout << i << yards << endl;
}
for (i=5; i<=100; i=i+5)
{
meters=getmeters();
cout << i << meters <<endl;
}
return 0;
}
double getyards (int x)
{
return (x*m2y);
}
double getmeters()
{
return 0;
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>what is the fatal error im getting and how do i resolve that?
That means that there were previous compile errors -- you can just ignore that line because it will go away after you get all the other errors fixed.
>>double getmeters(int);
Your post #6 does not have that line.
>>Nothing is working.
you are underestimating yourself, probably because you are so frustrated.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>your program is nearly complete
After re-reading the program requirements you are still pretty far from having it finished. But you need to get this to compile cleanly before continuing.
The getmeters() that I posted is wrong. It should return void and take a parameter by reference, such as void getmeters(int& meters);
After that you need to create the two tables that were in the program requirements.
>>It doesnt do anything like it, where did i go wrong?
You are right -- you have not implemented that part yet. What you need are two int arrays to hold the values your teacher wants. Below I just put in dummy numbers -- you need to put in the correct value. You can find them in any conversion calculator on the web.
int meters_to_yards[] = {0,1,2,3 ...}; // you have to use correct values here
int yards_to_meters[] = {0,1,2,3 ...}; // you have to use correct values here
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>with the other it worked fine. whats wrong?
Look everywhere in your program for getmeters and you will see the differences. That function must be passed one parameter by reference. And NO -- it did not work fine because the function must have one parameter.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Sorry towhoe but I can't help you any more this evening. I suspect this assignment is way beyond your ability to complete. you are just asking too many newbe questions and your assignment is for someone who already has some fundamental understanding of programming concepts. It's difficult to believe your teacher/school would give a first semester student an assignment that is so advanced.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
How do i go about getting a table in there. we have not covered this in class.
Then it's not something you want to do. It's not easy at your level of experience.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944