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

 
Counting age group
Reply
Posted 2004-10-17, 03: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
 



 
Reply
Posted 2004-10-17, 04:35 PM in reply to deadlock75's post "Counting age group"
I don't understand what you need.
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 



 
Array
Reply
Posted 2004-10-18, 12:55 PM in reply to WetWired's post starting "I don't understand what you need."
WetWired said:
I don't understand what you need.
When the program is running I don't want to user to input any age group instead I want to program that has already have the ages ready. Like the ages showing right now on the previous message.
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
 



 
Reply
Posted 2004-10-18, 01:36 PM in reply to deadlock75's post "Array"
int array[] = {4, 17, 79, 52, 56, 19, 21, 22, 3};
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes
 
 

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 02:58 AM.
'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.