Hello,
i have wrote a program using the while loop but it crashes whenever i run it
Basically, the goal of a program is to calculate the population of a town with constant 10% growth annually and then find how many years left.
here is my code (any help will be appreciated)
//Program1
// Chapter 5.4
#include<iostream>
using namespace std;
int const INITPOP = 900;
int const FINALPOP = 20000;
// prototype
int main()
{
int peopleCount;
float annualPerc = .1;
float yearsLeft,
annualGrowth;
peopleCount = INITPOP;
while (peopleCount < FINALPOP)
{
annualGrowth = annualPerc * INITPOP;
peopleCount = annualGrowth + INITPOP;
yearsLeft = FINALPOP / peopleCount;
peopleCount += peopleCount;
cout << peopleCount << yearsLeft << endl;
}
system("pause");
return 0;
}