I'm dabbling around with a regular C program that counts a number of inputs and categorizes them accordingly. I don't really have any code written up for it right now since I am still thinking of how to go about it, so I'll do my best to explain.
As an example of where I want to go with this program, lets say I want it to count the number of votes from people. I'm only interested in the demographics, not the actual votes. So, the user inputs the gender and age of each person with an individual ballot which then adds to a total number at the end and tallies between male and female. There would be a character assigned to each age bracket to help with the tally. For example ages 0-20 = A, 21-40 = B, 41+ = C. Then, there would be an input like X0 which would end the counting:
So it would look something like this with the gender and ages as the user input (ignore bullets):
- Enter gender and age: Male 17
- Enter gender and age: Female 20
- Enter gender and age: Male 30
- Enter gender and age: Female 46
- Enter gender and age: Male 35
- Enter gender and age: X0
- Male: ABB
- Female: AC
- Total: 5
I'm thinking of using while, for, and do while loops to get this accomplished since I am still learning the language, but I am having a hard time getting this going.
If you guys have any advice, it would be greatly appreciated.