Asked by ahmad
Write a C++ program that reads the population of
town A and its growth rate as well as the
population of town B and its growth rate. It
outputs after how many years the population of
town A will be greater than that of town B and the
values of their population at that time.
town A and its growth rate as well as the
population of town B and its growth rate. It
outputs after how many years the population of
town A will be greater than that of town B and the
values of their population at that time.
Answers
Answered by
MathMate
Here's a sample pseudocode.
Input initial populations, p1, p2.
Input growth rates, r1,r2.
Input number of years to print, n.
for year=0 to n
output year, p1*pow(1+r1,year), p2*pow(1+r2,year)
next year
If you have problems getting your code to work, post your code.
Input initial populations, p1, p2.
Input growth rates, r1,r2.
Input number of years to print, n.
for year=0 to n
output year, p1*pow(1+r1,year), p2*pow(1+r2,year)
next year
If you have problems getting your code to work, post your code.
There are no AI answers yet. The ability to request AI answers is coming soon!