Prepare a structure to store information on cat info (name , age , type). Create an array structured variable named CatInfo to received 2 inputs from user.
using namespace std;
//Prepare a structure to store information on cat info (name , age , type).Â
//Create an array structured variable named CatInfo to received 2 inputs from user.
#define ARRAY_SIZE 2
struct Cat
{
string Name;
string Type;
int Age;
};
main(void)
{
struct Cat CatInfo[ARRAY_SIZE];
int n;
for(n=0;n<ARRAY_SIZE;n++)
{
cout<<"\n\nEnter Cat-"<<n+1;
cout<<"\nEnter Name: "; cin>>CatInfo[n].Name;
cout<<"\nEnter Type: "; cin>>CatInfo[n].Type;
cout<<"\nEnter Age : "; cin>>CatInfo[n].Age;
}
cout<<"\n\nCat's Infoamation as entered:";
cout<<"\n\tName\t\tType\t\tAge";
for(n=0;n<ARRAY_SIZE;n++)
{
cout<<"\n\t"<<CatInfo[n].Name<<"\t\t"<<CatInfo[n].Type<<"\t\t"<<CatInfo[n].Age;
}
return(0);
}
Comments
Leave a comment