Ad Code

Responsive Advertisement

1160 - Population Increase

Author: Ismail Hosen

Daffodil International University





Problem Link

//Please follow from main function

#include<stdio.h>

int main()

{

    int pa, pb, y, i, t;

    double g1, g2;

    scanf("%d", &t);

    for(i=0; i<t; i++){

        scanf("%d %d %lf %lf", &pa, &pb, &g1, &g2);

        y=0;

        while(pa<=pb){

            pa=pa+((pa*g1)/100);

            pb=pb+((pb*g2)/100);

            y++;

            if(y>100){

                printf("Mais de 1 seculo.\n");

                break;

            }

        }

        if(y<=100){

                printf("%d anos.\n", y);

            }

    }

    return 0;

}




Post a Comment

0 Comments