Program to project world population - C++ Operator

C++ examples for Operator:Arithmetic Operator

Description

Program to project world population

Demo Code

#include <stdio.h>
#include <iostream>

int main(int argc, const char *argv[]) {
    long long int basePopulation = 7432699999;
    long long int population = basePopulation;
    long long int increase = 0;

    double growthRate = 0.0113f;
    int sample = 10;


    printf("\n*** Population projection for %d years ***\n", sample);

    printf("Year\t\tPopulation\t\tIncrease\n");

    for (int i = 1; i <= sample; i++) {
        increase = population * growthRate;

        printf("%d\t\t%lld\t\t%lld%s\n", i, population, increase,(population > basePopulation * 2) ? " - Population Doubled" : "");

        population += increase;/* w  ww .  j av a  2 s. c om*/
    }
    return 0;
}

Result


Related Tutorials