Initialisation is the of the main sources of error in programming, so always be aware of it.
I tend to declare my variables 1 per line, initialise them to something (as long as this doesn't cause problems later), and put a comment to say what the variable means.
HTH
Edit: You probably need to calculate what the monthly rate is.
"Run-Time Check Failure #3 - The variable 'monthlyrate' is being used without being initialized." - VS2012
I initialized it like the guy said from above, float L; float monthly; float interest; and the program still crashed.
Then I set default values because if you don't, it'll grab whatever memory was left in the RAM and use it.
Since you're passing monthlyrate to a function before it ever has a value, it crashes. (pow(x, y) is a function)
So the initialization you used would have been fine, if you had just set some default values, I think. Just to be safe, it'd be good programming practice to declare your variables line - by - line and set default values for each one.
I initialized it like the guy said from above, float L; float monthly; float interest; and the program still crashed.
That is declaration, not initialisation. Initialisation means assigning a value, which you are calling a default value.
Default value has a special meaning in C++, namely in assigning a value to a parameter of a function, which means that the user does not have to supply an argument in the function call, unless they want a value different to the default value.
@Reaper1
As I said above you need to calculate the value of monthlyrate, before you use it on line 24.
I did initialize it and it works for me, the only part that wrong it the interest part. If i enter the the numbers i wrote above interest should show 1957.16 , but i get 0.36 everytime, i know im missing something in interest calculation but i dont know what heres my updated code.
Ok i will , how can i get the right answer in the interest line 27, its outputting the wrong number. i know why it is, im just having trouble figuring out what the right equation would be.
ok ill post the problem dont worry im not in school, im teaching myself c++ , c# , java, perl , ruby , assembly , and pretty much every other language.
heres the problem and the input for the problem and what it should look like.
18. Monthly Payments
The monthly payment on a loan may be calculated by the following formula:
Rate is the monthly interest rate, which is the annual interest rate divided by 12. (A 12
percent annual interest would be 1 percent monthly interest.) N is the number of payments
and L is the amount of the loan. Write a program that asks for these values and displays
a report similar to the following: