Hi I have the following code:
#include<stdio. h>
#include<math.h >
int main(void)
{
double Population,capa city,initial;
int generations;
float growth;
printf("Please give the carrying capacity of the environment: ");
scanf("%lf", &capacity);
printf("Please give the intrisic growth rate: ");
scanf("%f", &growth);
printf("Please give the inital population of the species: ");
scanf("%lf", &initial);
Population=init ial*exp (growth)*(1-(initial/capacity));
printf("The population at the next generation will be: %.2f\n", Population);
initial=Populat ion;
printf("Please indicate how many generations you wish to calculte: ");
scanf("%d", &generations );
for(generations =2; generations<=80 ; initial==Popula tion)
{
Population+=Pop ulation*exp (growth)*(1-(Population/capacity));
printf("The population at the next generation will be: \n");
}
return(0);
}
and I cannot get my loop to function correctly!! I need to make it so that the loop performs the calculations for generations 2 through 80 each time using the previously calculated value of Population as the "initial" variable in the next calculation and then how to break it once it has calculated the population at the 80th generation?
#include<stdio. h>
#include<math.h >
int main(void)
{
double Population,capa city,initial;
int generations;
float growth;
printf("Please give the carrying capacity of the environment: ");
scanf("%lf", &capacity);
printf("Please give the intrisic growth rate: ");
scanf("%f", &growth);
printf("Please give the inital population of the species: ");
scanf("%lf", &initial);
Population=init ial*exp (growth)*(1-(initial/capacity));
printf("The population at the next generation will be: %.2f\n", Population);
initial=Populat ion;
printf("Please indicate how many generations you wish to calculte: ");
scanf("%d", &generations );
for(generations =2; generations<=80 ; initial==Popula tion)
{
Population+=Pop ulation*exp (growth)*(1-(Population/capacity));
printf("The population at the next generation will be: \n");
}
return(0);
}
and I cannot get my loop to function correctly!! I need to make it so that the loop performs the calculations for generations 2 through 80 each time using the previously calculated value of Population as the "initial" variable in the next calculation and then how to break it once it has calculated the population at the 80th generation?
Comment