Well I'm not sure if my source code is missing anything, or if i'm just using the Dev-C++ incorrectly, but I'm writing a code that compounds interest yearly. When running the program the command window pops up VERY briefly and closes. I don't even get to see the values. What do you guys suggest? All I have in my project is the source code ( here, just in case I missed something in my code)
// Calculating compound interest.
include <iostream>
using std::cout;
using std::endl;
using std::ios;
using std::fixed;
include <iomanip>
using std::setw;
using std::setprecision;
include <cmath>
int main()
{
double amount, principal = 1000.0;
double rate = .05;
cout<<"year"<<setw(21)<<"amount on deposit"<<endl;
// set floating-point number format
cout << fixed << setprecision(2);
//calculate amount on deposit for each of ten years
for ( int year = 1; year <= 10; year++ )
{
//calculate new amount for specified year
amount = principal * pow(1.0+rate, year);
//output one table row
cout << setw(4) << year << setw(21) << amount << endl;
} // end for
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sigh I suggest reading the "PLEASE READ BEFORE POSTING A QUESTION" thread. It answers this exact question. It is normal behaviour when a program terminates that its Window should close, but people remain surprised when it happens to their programs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well I'm not sure if my source code is missing anything, or if i'm just using the Dev-C++ incorrectly, but I'm writing a code that compounds interest yearly. When running the program the command window pops up VERY briefly and closes. I don't even get to see the values. What do you guys suggest? All I have in my project is the source code ( here, just in case I missed something in my code)
// Calculating compound interest.
include <iostream>
using std::cout;
using std::endl;
using std::ios;
using std::fixed;
include <iomanip>
using std::setw;
using std::setprecision;
include <cmath>
int main()
{
double amount, principal = 1000.0;
double rate = .05;
}
> What do you guys suggest?
sigh I suggest reading the "PLEASE READ BEFORE POSTING A QUESTION" thread. It answers this exact question. It is normal behaviour when a program terminates that its Window should close, but people remain surprised when it happens to their programs.