After studying the population of Gotham City in the last decade of the twentieth
ID: 3545701 • Letter: A
Question
After studying the population of Gotham City in the last decade of the twentieth century the population is modeled as
P(t) = 52.966 + 2.184t
where t is years after 1990 and P is population in thousands
. P(0) represents the population in 1990 which was 52.966 thousand people.
Write a program that defines a function named population that predicts Gotham's population in the year provided as an input argument. The program must call the function and interacts with the user as follows
Enter a year after 1990> 2015
Predicted Gotham City population for 2010 (in thousands): 107.566
Explanation / Answer
#include<stdio.h>
float population(int a)
{float p=52.66+(a-1990)*2.184;
return p;}
int main()
{
int year;
float p;
printf("Enter a year after 1990 : ");
scanf("%d",&year);
p=population(year);
printf("Predicted Gotham City population for %d (in thousands): %f",year,p);
return 0;
}