The statement reads:
In 1994, country A has a population of 25 million people and country B of 19.9 million.
rates of population growth is 2% and 3% respectively.
develop an algorithm to tell which year the population of country B than to A.
As the idea that emerges from the statement is to go by several consecutive calculations to determine what year it happens, we will use a WHILE CYCLE for our calculations.
# include \u0026lt;iostream.h>You see, with the number of times running cycle WHILE provided the data in country B is less than in country A, we calculate how many years pass, and then use a variable to add the number of iterations initial value is 1994.
double a = 25;
double b = 19.9;
int main (void )
{court \u0026lt;\u0026lt;"Welcome" \u0026lt;\u0026lt;endl \u0026lt;\u0026lt;endl;
system ("pause");
court \u0026lt;\u0026lt;"In the year 1994" \u0026lt;\u0026lt;endl;
court \u0026lt;\u0026lt;"The initial population of country A is 25 million people" \u0026lt;\u0026lt;endl \u0026lt;\u0026lt;endl;
system (" pause ");
court \u0026lt;\u0026lt;" The initial population of country B is 19.9 million people "\u0026lt;\u0026lt;endl \u0026lt;\u0026lt;endl;
system ("pause");
court \u0026lt;\u0026lt;"If the population to grow at a rate of 2% per year \\ nIf the population of B grows at a rate of 3% \\ n" \u0026lt;\u0026lt;endl \u0026lt; ; \u0026lt;endl; system("pause");
int c=0;
while (a> b)
{a = a + (a * 0.02);
b = b + (b * 0.03 )
c + +;}
int d;
d = 1994 + c;
court \u0026lt;\u0026lt;"The population of country B exceeds that of country A in the year" \u0026lt;\u0026lt;d \u0026lt;\u0026lt; endl;
court \u0026lt;\u0026lt;"Thank you for using this program" \u0026lt;\u0026lt;endl \u0026lt;\u0026lt;endl;
system ("pause");
return 0;}
0 comments:
Post a Comment