Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

roblem 1 (15 points): After studying the population growth of Gotham City in the last deende of the 20th Century, we have modeled Gotham's popalation

image text in transcribed
roblem 1 (15 points): After studying the population growth of Gotham City in the last deende of the 20th Century, we have modeled Gotham's popalation function a P(t) 52.966+2.184t, where t is the number of years after 1990, and P is the population in thousands. Thus 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. Write a program that calls the population function and interacts with the user as follows: Sample Code Execution: Red text indicates information entered by the user Enter a year after 1990: 2015 Predicted Gothan City population for 2015 (in thousanda): 107,566 Problem 2 (15 points): Write a C program that computes the sum of a series. Your program should use the following two functions. long int power(int base, int exp); long int series(int n, int j); function returns base raised to the exp power whereas the second function returns the series sum Sample Code Execution: Red text indicates information entered by the user Enter the values of n and j:52 1^2 2"2 + 3"2 + 4^2 + 5^2 55 = + Problem 3 (20 points): Write a program that finds all prime numbers from 1 to 1,000,000. Your program should call a user-defined function called "primes" that returns PASS (i.e., 1) i otherwise. The function prototype should be as follows: f a number is prime and FAIL (i.e., 0), int prime(int p): A prime number (or a prime) is a natural mumber that has exactly two distinct divisons: 1 and itselt. for primality testing use the following algorithm. Algorithm: Let n be the number tested for primality. If n is not divisible by any number m smaller than [Vnl then n is a prime. Else n is not a prime

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions