there are 9000 in a town whose population increases by 15%each yr. write a program that displays the annual population and determines the no. of yrs it will take for the population to surpass 50000 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

there are 9000 in a town whose population increases by 15%each yr. write a program that displays the annual population and determines the no. of yrs it will take for the population to surpass 50000

22nd Sep 2016, 2:15 AM
Meena
Meena - avatar
2 Answers
+ 5
int population, p = 9000; float increase, inc = .15; int overpopulation, op = 50000; int year = 1; cout << "year: 0" << " pop: " << p << endl; for (p; p <= op; ++year){ p += p*inc; cout << "year: " << year << " pop: " << p << endl; } best i could do.
22nd Sep 2016, 7:35 AM
TylerFrost
TylerFrost - avatar
0
please help me understand, why use ++year, and not year ++?
18th Nov 2016, 6:38 PM
Benedek Máté Tóth
Benedek Máté Tóth - avatar