Array and Pointer help

This is a discussion on Array and Pointer help within the C Programming forums, part of the General Programming Boards category; I was wondering if someone would be able to give me a hint on how I would start this program. ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    1

    Array and Pointer help

    I was wondering if someone would be able to give me a hint on how I would start this program. Any help help would be great. I know I am supposed to use arrays and/or pointers. The problem is as follows:

    Letís investigate the way that population grows. We know that the changes in population
    come from three sources: birth, death, and net immigration.

    The number of births depends on the population and age distribution of the fecund women.
    Letís model the number of births per year by women of age A by the expression F*[(13−|28−A|) /169.0 ]*W(A),
    where F is the average number of children per woman, and W(A) is the population of women aged A, and where we assume that only women between age 16 and 40 will give birth. The total number of births is the sum of all these amounts, and we will split evenly between males and females.

    The death rate depend on the age and sex of the population, and is dependent on two factors: childhood illnesses and old age. Letís model the childhood illness deaths by 0 if A is >=10 and CI [(10−A)/55.0 ]*P(A) for A < 10, where CI is the probability of dying from a childhood illness and P(A) is the population of each sex of age A [youíll have to handle the two sexes separately].
    Letís also model the old age deaths by the smaller of P(A) and D *[A^2 /10000.0]* P(A), where D is a measure of the average life for a particular sex [so there are really two Dís, one for men and one for women].

    The number of migrants also depends on age, but (weíll assume) not on sex. Letís model
    the increase due to migration by M ∑ P(A) for ages between 20 and 40, and by (M/2) ∑ P(A) for ages between 0 and 19. [Again you will have to handle each sex separately.]

    For your program, I want you to set aside two arrays: one for the male population and one
    for the females, each one to range for ages from 0 to 100. Put 100 people of each sex into
    each age from 0 to 40. Then read in the five floating values: F, CI, Dmale, Dfemale, and M
    (in that order). Repeat the following 100 times:

    compute the number of births (and store in a temporary variable)

    for each sex, working from age 100 down to age 1, figure the new P(A) from P(A−1)
    plus net immigration minus deaths from childhood illness and from old age

    for each sex, the new P(0) is half the number of births

    Finally print the two arrays.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    1) Identify the problem in your own words.
    2) Solve on paper using math and English or an equivalent natural language.
    3) Break down your solution to basic steps, still not in C.
    4) Translate your solution to C.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 02:17 PM
  2. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21