Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


If P is the population on the first day of the year, B is
the birth rate, and D is the death rate, the estimated
population at the end of the year is given by the formula:

The population growth rate is given by the formula:
B – D
Write a program that prompts the user to enter the starting
population, birth and death rates, and n, the number of
years. The program should then calculate and print the
estimated population after n years. Your program must have
at least the following functions:
1. growthRate: This function takes its parameters the
birth and death rates, and it returns the population growth
rate.
2. estimatedPopulation: This function takes its
parameters the current population, population growth rate,
and n, the number of years. It returns the estimated
population after n years
Your program should not accept a negative birth rate,
negative death rate, or a population less than 2.



If P is the population on the first day of the year, B is the birth rate, and D is the death rate,..

Answer / chaitanya raj budumuru

#include <iostream.h>
#include <conio.h>

class population
{
int b,d,p,n,c;
public:
void read()
{
c=1;
do
{
if(c>1)
{
cout<<"\n\nYou are entered wrong input";
cout<<"\nPress Enter And Re-Enter The Input";
getch();
c++;
}
clrscr();
cout<<"Enter The Birth and Death Rates:\n\t\t";
cin>>b>>d;
cout<<"\n\nEnter The current population:\n\t\t";
cin>>p;
cout<<"Enter How many Years Estimated:\n\t\t";
cin>>n;
}while(b<0&&d<0&&p<2);
}
int growth_rate(int b,int d)
{
return(b-d);
}
int estimatedPopulation(int p,
int growthrate(b,d),
int n)
{
for(int i=1;i<=n;++i) p=p+growthrate(b,d);
return p;
}
void execute()
{
read();
cout<<"The Population after"<<n<<"years"
<<estimatedPopulation(p,growthrate(b,d),n);
}
};

void main()
{
clrscr();
population pop;
pop.execute();
getch();
}

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C++ General Interview Questions

Explain one-definition rule (odr).

0 Answers  


Write a code/algo to find the frequency of each element in an array?

0 Answers   Axtria,


what is an array

20 Answers  


Write a C++ program to sort digits of all the 4 digit number and display the sorted 4 digit number

1 Answers   TATA, TCS,


What is guard code in c++?

0 Answers  


Can we use struct in c++?

0 Answers  


Do we have to use initialization list in spite of the assignment in constructors?

0 Answers  


structure that describe a hotel with name, address,rooms and number of rooms

2 Answers  


What's the order in which the objects in an array are destructed?

0 Answers  


What is a type library?

0 Answers  


What do you mean by vtable and vptr in c++?

0 Answers  


What are features of c++?

0 Answers  


Categories