#include %26lt;iostream.h%26gt;
void main()
{
float amount,ratepercent,years,rate,counter;
cout%26lt;%26lt;"Please type in the amount of money: ";
cin%26gt;%26gt;amount;
cout%26lt;%26lt;"Please type in the interest rate (in percentage): ";
cin%26gt;%26gt;ratepercent;
cout%26lt;%26lt;"Please type in the number of years: ";
cin%26gt;%26gt;years;
rate=(100+ratepercent)/100;
for(counter=1,counter%26lt;=years,counter+...
{
amount=amount*rate;
}
cout%26lt;%26lt;"The total amout of money at the end of the "%26lt;%26lt;years%26lt;%26lt;" is "%26lt;%26lt;amount%26lt;%26lt;endl;
}
1.cpp
d:\koleya\intro\section\square\intrest... : error C2143: syntax error : missing ';' before ')'
d:\koleya\intro\section\square\intrest... : error C2143: syntax error : missing ';' before ')'
Error executing cl.exe.
intrest.exe - 2 error(s), 0 warning(s)
Anyone has any answer for that error?!
A C++ error that I dun know its origin... error C2143: syntax error : missing ';' before ')'?
You're using commas in the for-loop, rather than semi-colons...
for(counter=1, counter%26lt;=years, counter++)
should be
for(counter=1; counter%26lt;=years; counter++)
Note that it's not smart to use a float as a counter variable. Try using an int instead.
Also note that there's a much faster way (much faster in most cases) to calculate the interest:
http://math.about.com/library/weekly/aa0...
Reply:The for loop should have semicolon instaead of comma
for(counter=1 ; counter%26lt;=years ; counter++)
apple
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment