not working right!!!

There's something wrong with my program and i am failing to find what it is.
apparently the second function is not working.
Thanks.

#include<iostream>
#include<stdlib.h>
using namespace std;

double convertToYen(double);

int main()
{
double amountus =0.0;


cout<< "Enter the amount in U.S dollar ";
cin>>amountus;
double convertToYen (double amountus);

system("pause");
return 0;
}

double convertToYen(double amountus)
{
double amountyen=0.0;

amountyen = amountus * 86.07;
cout<<" The equivalent amount in japenese yen: "<< amountyen<<endl;

}
look at line 14 then read this http://www.cplusplus.com/doc/tutorial/functions/ you are calling your function incorrectly.
Yeah the problem must b from how you call the function. Call it this way:
convertToYen(amountus) ;
Not: double convertToYen(double amountus) ;

Aceix.
Aside from the fact (as has already been pointed out in previous posts) that your reference to convertToYen in main is a function declaration, the code should not compile with no value being returned from convertToYen as long as it has a return type of double.
Thanks for the help everybody.
@cire: nope, a warning at most.
ne555 wrote:
nope, a warning at most.


Sad, that is. Apparently all the standard has to say about it is:

6.6.3.2
Flowing off the end of a function is equivalent to a return with no value; this results in undefined
behavior in a value-returning function.

And the standard doesn't require a diagnostic for undefined behavior, although, since it is trivially detectable in cases where there are no return statements in the function body, one would expect a warning as a QOI issue.

MSVC++ generates an error by default for functions that can be proved don't return values and a warning for cases where it just may be the case. (That behavior can, of course, be adjusted.)
> MSVC++ generates an error by default for functions that can be proved don't return values
> and a warning for cases where it just may be the case.

Kudos to MSVC for that; IMHO the MSVC default behaviour should be the default in every compiler.

If it can be detected by static flow analysis that that the code is patently incorrect, issue an error diagnostic; and if it may be incorrect, issue a warning diagnostic.
Topic archived. No new replies allowed.