#include <stdio.h>
int main() {
float invest = 1000;
int num_years = 0;
while(invest < 2000) {
invest = invest + (invest * 0.05);
printf("Investment = %0.2f\n", invest);
num_years++;
}
printf("\nIt took %d years for 1000 to double\n", num_years);
///////////////////////////////////////////////////////
float invest_2 = 5000;
int i;
for (i = 0; i < 5; i++) {
invest_2 = invest_2 + (invest_2 * 0.10);
}
printf("\n5000 turned into %0.2f in 5 years\n", invest_2);
return 0;
}
Editor is loading...