Q23 Population of a town today is 100000. The population has increased steadily at the rate of 10% per year for last 10 years. Write a program to determine the population at the end of each year in the last decade.
Program: 116
Population of a town today is 100000. The population has increased steadily at the rate of 10% per year for last 10 years. Write a c program to determine the population at the end of each year in the last decade.
Output:
1 year: 90000 2 year: 81000 3 year: 72900 4 year: 65610 5 year: 59049 6 year: 53144 7 year: 47829 8 year: 43046 9 year: 38742 10 year: 34867
i think the solution is wrong. The question is asking for something else. check it out.
#include<stdio.h>
#include<math.h>
int main()
{
int x,i;
x=10000/pow(1.1,10);
for(i=10;i>=1;i–)
{
x=100000/pow(1.1,i);
printf(“Population %d years ago: %d\n”,i,x);
}
return 0;
}
OUTPUT:
Population 10 years ago: 38554
Population 9 years ago: 42409
Population 8 years ago: 46650
Population 7 years ago: 51315
Population 6 years ago: 56447
Population 5 years ago: 62092
Population 4 years ago: 68301
Population 3 years ago: 75131
Population 2 years ago: 82644
Population 1 years ago: 90909
current year population is 100000, and in last ten years it increases every year at 10%.
sir why you use “(int)pop”
Because pop has been declared as a float variable so after calculation the final value of pop we need to print it and to make it an integer value we have to add (int) before declaring the path of the printing value.