Name needs at least four elements to accomadate the NULL terminator placed at the end of strings.
This program could also be compacted a little more:
Code:
#include <stdio.h>
#include <string.h>
int main()
{
int age;
char name[4];
printf( "Enter name of animal: " );
scanf( "%s", name );
if (!strcmp(name, "dog") || !strcmp(name, "cat"))
{
printf( "ok, its a %s\n", name);
printf( "enter age: " );
scanf( "%d", &age );
printf("your %s is %d years old which is %d in human years\n", name, age, age*7);
}
else
printf("I've never heard of a %s\n", name);
getchar();
getchar();
getchar();
return 0;
}
Next you could try to create a simple database program that asks the user to enter records and allows him get information for a record.