Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Community Calendar Today's Posts Search
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next

 
Counting age group
Reply
Posted 2004-10-17, 04:52 PM
I need some help I wrote a program to count th number of people in each of the following groups: 0-16 infant, 16-29 young, 29-55 middle age, 55-75 old, 75- and older, really old. I have the program so that the user can input the ages but the part I do not know how to do is how to assign the numbers in a array to show me the aged group.

#inlcude <stdio.h>
main()
{
int age, group1=0, group2=0, group3=0, group4=0, group5=0;
printf ("Please enter an integer, when done enter -1\n");
scanf("%d", &age);
while (age>=0)
{
if (age<=16)
group1=group1+1;
else if (age<=29)
group2=group2+1;
else if (age<=55)
group3=group3+1;
else if (age<=75)
group4=group4+1;
else
group5=group5+1;
}
printf ("Please enter an integer, when done enter -1\n");
scanf("%d", &age);
printf("\n Results\n");
printf("In group age 0-16 we have individuals\n", group1);
printf("In group age 16-29 we have individuals\n", group2);
printf("In group age 29-55 we have individuals\n", group3);
printf("In group age 55-75 we have individuals\n", group4);
printf("In group age 75-old we have individuals\n", group5);
}

I am trying to assign these numbers in an array
4 17 79 52 56 19 21 22 3
12 30 33 81 99 85 28 24 25
24 26 27 20 44 32 35 24 39
43 41 46 56 62 22 20 69 18
Old
Profile PM WWW Search
deadlock75 is neither ape nor machine; has so far settled for the in-betweendeadlock75 is neither ape nor machine; has so far settled for the in-between
 
deadlock75
 



 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 10:55 PM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.