Answer to Question #202654 in C++ for Syasya

Question #202654

Prepare a structure to store information on cat info (name , age , type). Create an array structured variable named CatInfo to receive 2 inputs from user.


1
Expert's answer
2021-06-03T13:42:22-0400


#include <iostream>


using namespace std;
struct Cat
{
  string name;
  int age;
  string type;
};
int main()
{
    struct Cat CatInfo[2];
    for (int i=0;i<2;i++){
        cout<<"\nEnter the name of cat "<<i+1<<":";
        cin>>CatInfo[i].name;
        cout<<"\nEnter the age of cat "<<i+1<<":";
        cin>>CatInfo[i].age;
        cout<<"\nEnter the type of cat "<<i+1<<":";
        cin>>CatInfo[i].type;
    }
    for (int i=0;i<2;i++){
        cout<<"\nName : "<<CatInfo[i].name;
        cout<<"\nAge : "<<CatInfo[i].age;
        cout<<"\nType : "<<CatInfo[i].type;
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog