#include <stdio.h>
#include <ctype.h>
// ww w .j ava2 s .c o m
struct cat
{
int age;
int height;
char name[20];
char father[20];
char mother[20];
};
int main()
{
struct cat myCat[50];
int hcount = 0;
int i = 0;
char test = '\0';
for(hcount = 0; hcount < 50 ; hcount++ )
{
printf("\nDo you want to enter details of a%s cat (Y or N)? ", hcount?"nother " : "" );
scanf(" %c", &test );
if(tolower(test) == 'n')
break;
printf("\nEnter the name of the cat: " );
scanf("%s", myCat[hcount].name );
printf("\nHow old is %s? ", myCat[hcount].name );
scanf("%d", &myCat[hcount].age );
printf("\nHow high is %s ( in hands )? ", myCat[hcount].name );
scanf("%d", &myCat[hcount].height );
printf("\nWho is %s's father? ", myCat[hcount].name );
scanf("%s", myCat[hcount].father );
printf("\nWho is %s's mother? ", myCat[hcount].name );
scanf("%s", myCat[hcount].mother );
}
for (i = 0 ; i < hcount ; i++ )
{
printf("\n\n%s is %d years old, %d hands high,",myCat[i].name, myCat[i].age, myCat[i].height);
printf(" and has %s and %s as parents.", myCat[i].father,myCat[i].mother );
}
}