Can't fix warning- some input...

• 05-11-2009
ninety3gd
Can't fix warning- some input...
Got a warning...like to fix...(I know warning are generally fine...but want to fix)- In bold

20 C:\Documents and Settings\HP_Owner\Desktop\PA2C.cpp [Warning] passing `double' for converting 3 of `double futureInvestmentValue(double, double, int)'

Code:

```#include <iostream> #include <cmath> using namespace std; double futureInvestmentValue(double IA, double MIR, int NOY); int main() {   double investmentAmount, annualInterestRate, numOfYears,  monthlyInterestRate, futureValue;     cout << "Enter investment amount: ";   cin >> investmentAmount;   cout << "Enter monthly interest rate: ";   cin >> annualInterestRate;   cout << "Enter number of years: ";   cin >> numOfYears;   monthlyInterestRate = annualInterestRate / 1200;     futureValue = futureInvestmentValue(investmentAmount,monthlyInterestRate,numOfYears);   cout << "Future value is " << futureValue << endl;     return 0; } double futureInvestmentValue(double investmentAmount, double monthlyInterestRate, int numOfYears) {     double accumulatedValue;          accumulatedValue = investmentAmount * pow(1 + monthlyInterestRate, numOfYears * 12);         return accumulatedValue; }```
• 05-11-2009
neha007
we enginners bother only about errors not WARNINGS !!!!!!!!!!!!!!!!!!!

so ignore it

...
• 05-11-2009
yaya
It is a warning, so you can ignore it. But the problem is that you have said that numOfYears is a double, when the futurInvestmentValue function is asking for an int.
• 05-11-2009
Tonto
Your third parameter 'numOfYears' to the function is supposed to be an int, but you pass it a double

Code:

`double investmentAmount, annualInterestRate, numOfYears,  monthlyInterestRate, futureValue;`
So you get an implicit type conversion

Floating to Integral (C++)
Standard Conversions (C++)
• 05-12-2009
Salem
> we enginners bother only about errors not WARNINGS !!!!!!!!!!!!!!!!!!!
> so ignore it
You're not an engineer then.

All warnings are errors.

If you have warnings, you're on the slippery slope of seeing "how much can I get away with before it breaks".
One or two is OK (usually), but by the time you're up into the 1000's, you've got a big-assed problem on your hands.

What's worse, with 1000's of warnings, you just don't see 1001 appear as one you REALLY should be paying attention to.
• 05-12-2009
ninety3gd
Thanks got the warning fixed...