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.

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.

#include<stdio.h>
#include<conio.h>
int main()
{
    int i;
    float pop=100000;
    //for-loop for 10 years
    for(i=1;i<=10;i++)
    {
        pop = pop - pop*0.1; //10 % of population
        printf("%d year: %d\n",i, (int)pop);
    }
}

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

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

View Comments (4)

  • 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%.

    • 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.

Related Post
Leave a Comment

This website uses cookies.