Write a C program which calculates and displays each year’s population of egrets based of some user input and the following formula: NetYr= Rate*CurrentYr*(1-CurrentYr/1000000)
Please at least give me an idea
It would seem to me that you will ask the user for the span they are interested in, and then you just plug it into that equation.
@eSpex u r right on the money.
Do you know how to get input from a user?
Requirements: • The program must read input from the user for the initial value of CurrentYr. Valid input for this value is an integer greater than 0 and less than 1000000. • The program must read input from the user for the value of Rate. Valid input for this value is a real number greater than 0 and less than 4. • For each of the values which the user must enter (CurrentYr and Rate), if any invalid input (including negative numbers) is entered, then a message informing the user of the valid ranges must be displayed and the user be given a second chance to enter the number. If invalid input is entered on the second chance then the program must terminate with a message that the input can’t be used and without doing any population change calculations. • The program is only required to work if an integer is entered by the user for CurrentYr and a numeric value is entered for Rate – i.e. you can assume that the correct type of input is obtained although you must check whether or not it is in the valid range. • The program must display the initial population entered by the user (as year 0), followed by the population for each of the next 25 years found by applying the formula above, in the format shown in the sample run below. • If the calculated value for NextYr includes a fractional part, the fractional part must be dropped. • Use comments to show the main steps in the program (e.g. /* Read input from user */), and to document variable declarations (e.g. /* growth rate */). • A sample run of your program should look like: Enter the initial egret population: 100000 Enter the rate: 2.6 Year Population ---- -- -------- 0 100000 1 234000 2 466034 3 647000 4 593816 5 627116 And so on…
am sorry it is too long. anywho i got something started /* Write a C program to find population for each upcoming 25 years */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { int Cy, Ny; double r; } { int (Cy >0 && <=1000000) } clrscr(); printf("Enter the values of Cy,r and Ny \n"); scanf ("%f %f %d", &Cy, Ny, &r); Ny = Cy*R(1-) }
i see i did n't finish the Ny equation and some of the declarations.
am i in the right track?
Yes, I would however, take the inputs one at a time so that you can check them. By doing repeated inputs you can work on getting one input/check working and then copy it to the other variables you want.
will do. thanks
Can I send u the program so u can see u how far I go with it and help me?
@eSpeX ?
You are always welcome to use pastebin or ideone to share your code, then copy a link here for people to help you.
Join our real-time social learning platform and learn together with your friends!