-
Junior Member
Question!!!
I hav another question wanna ask..... The question is as below:
Write a program that contains 2 arrays which contained name and age
Name Age
Rose 8
Jack 13
Jin 20
Katty 34
1st array stored the names and 2nd array stored the age.
classify them into children, teenagers and adult according 2 age. The output(name,age,classification)are to be saved in an output file.
thanks a lot....
-
Junior Member
Re: Question!!!
#include<stdio.h>
main()
{
int num[10],i,n,child,teenager,adult,name;
clrscr();
printf("How many elements?");
scanf("%d",&n);
printf("\nEnter %s and %d=",name,n);
for(i=0;i<n;i++)
scanf("%d",&num[i]);
adult=num[0];
for(i=0;i<n;i++)
{
if(num[i]>adult)
adult=num[i];
}
second=-999
for(i=0;i<n;i++)
{
if(num[i]!=adult)
if(num[i]>teenager)
teenager=num[i]
else
child=num[i];
}
printf("\nAdult=%d",adult);
printf("\nTeenage=%d",teenager);
printf("\nchild=%d",child);
getch():
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules