Thread: How to stratify a population?

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

    How to stratify a population?

    Hello there,
    I am new to this board. Let me introduce myself, I'm Matt, 21yo, beginner in C, french.
    I got a problem here.
    I do not know how to stratify a population. By that I mean I want to do the following (examples):

    Code:
    individual[1] = {18, 2, 1600, 3, TRUE}
    individual[2] = {7, 1, 1700, 2, FALSE}
    individual[3] = {41, 2, 1800, 2, FALSE}
    individual[4] = {72, 1, 1500, 1, TRUE}
    

    On a total of 100 individuals, so I guess individual[100] would be the population's amount.
    But I would like to set settings for each individual in this population. So that I can make individuals into categories.
    The values I showed stand for (age, job, salary, religion, bool isInASyndicate)
    Then I could obtain the number of syndicated people, adult people, children people, muslim and christian people etc. into variables like
    int numberOfFactoryWorkers
    int numberOfMuslims
    int numberOfAdults
    int numberOfSeniors
    Etc.
    int populationTotal...

    Thank you very much for helping me!

  2. #2
    Registered User
    Join Date
    Oct 2019
    Posts
    81
    I'm not sure what exactly you are asking because your question is too general.

    But for a start, if you haven't done this already.... You probably need to declare a struct where you store your values

    Code:
    typedef struct{
    
    int age;
    int job;
    int salary;
    int religion;
    bool isInASyndicate;
    
    }individual;
    Put the struct into use in storing your data:

    Code:
    individual individuals[100];
    Possibly zero initialize all your structs then populate possibly from user input etc

    So, what exactly are you having a problem doing? Where have you got?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Struct Population Problems in C
    By Sexy Frog in forum C Programming
    Replies: 1
    Last Post: 02-13-2017, 02:25 AM
  2. Replies: 3
    Last Post: 11-16-2011, 08:42 AM
  3. Sort by population or area
    By the_lumin8or in forum C++ Programming
    Replies: 3
    Last Post: 09-30-2006, 07:12 AM

Tags for this Thread