I want to have a code to this problem in C++.
please help me!!!

Here the problem!!!

"The rate of increase in population of a certain kind of bacteria is proportional to the population at any time. if in the last eight years, the population increased from 50000 to 120000,what will be the population of bacteria 16 years from now??"

This seems like a homework/project problem given by your teacher or professor but I will try to help you either way. When the problem says proportional, I am guessing that means they are the same. If so this should do the trick:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    double population;
    double population2;
    double difference;
    double years;
    
    cout<<"What is The Population 8 Years Ago?\n"; //Should Be 50000
    cin>>population;
    cout<<endl;
    cout<<"What is The Population Now?\n"; //Should Be 120000
    cin>>population2;
    cout<<endl;
    difference = (population2 - population); //Takes 120000 - 50000 to Find the Gain Over 8 Years
    years = (difference + difference); //Adds The Two Differences
    cout<<"The Population Over 16 Years is: "<<(years + years)<<"\n"; //Adds the Two Differences to Give The Population Over 16 Years
    cout<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

691200

691200

How are you achieving this answer if you do not mind me asking? Proportional means the same does it not?

pro·por·tion·al
adjective /prəˈpôrSHənl/ 

1. Corresponding in size or amount to something else

The last code I provided showed it over 16 years in all but not 16 years after the 8 years that had already passed. This should be correct:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    double population;
    double population2;
    double difference;
    double years;
    
    cout<<"What is The Population 8 Years Ago?\n";
    cin>>population;
    cout<<endl;
    cout<<"What is The Population Now?\n";
    cin>>population2;
    cout<<endl;
    difference = (population2 - population);
    years = (difference + difference);
    cout<<"The Population Over 16 Years is: "<<(years * 4)<<"\n";
    cout<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

It sounds to me like a compound interest question, hence my answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.