Answer the question
In order to leave comments, you need to log in
Where to enter printf?
I am taking the cs50 course, the task of the laboratory task is as follows:
Complete the implementation of population.c, such that it calculates the number of years required for the population to grow from the start size to the end size.
Your program should first prompt the user for a starting population size.
If the user enters a number less than 9 (the minimum allowed population size), the user should be re-prompted to enter a starting population size until they enter a number that is greater than or equal to 9. (If we start with fewer than 9 llamas, the population of llamas will quickly become stagnant!)
int population = get_int("set a starting population size:")
if (population<9)
printf ("the minimum allowed population size is 9")
return population;
#include <cs50.h>
#include <stdio.h>
int get_number(void);
int main(void)
{
int i=get_number();
printf("%i\n", i);
}
int get_number(void)
{
int n;
do
{ n= get_int("set a starting population size: ");
}
while (n<9);
return n;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question