How do I get the program to take the "Population " calculated from the first time and use it as the "initial" variable for the next calculation. And for it to continue to do this for generations 2 on each time taking the previously calculated Population and using it as the variable "initial" for the next calculation. With what I have right now when I run the program it just kind of... pauses after I give all the inputs.
Code:
#include<stdio.h>
#include<math.h>
int main(void)
{
double Population,capacity,initial;
int generations;
float result,growth;
printf("Please give the carrying capacity of the environment: ");
scanf("%lf", &capacity);
printf("Please give the intrisic growth rate: ");
scanf("%f", &growth);
result=exp (growth);
printf("Please give the inital population of the species: ");
scanf("%lf", &initial);
printf("Please indicate the number of generations: ");
scanf("%d", &generations);
Population=initial*result*(1-(initial/capacity));
for(generations = 2; generations <=80; initial= Population)
Population=initial*result*(1-(initial/capacity));
printf("The expected population at the next generation is: %.6f\n",Population);
return(0);
}
Comment