Monday, 30 September 2024

Journal Program 13

 #include<iostream.h>

#include<conio.h>

class Cricketer

{

int age,tmatch,trun,twicket;

char name[20],country[20],type[10];

public:

void getData()

{

cout<<"Enter name=";

cin>>name;

cout<<"Enter age=";

cin>>age;

cout<<"Enter country=";

cin>>country;

cout<<"Enter type(Bat/Bow)=";

cin>>type;

cout<<"Enter total matches=";

cin>>tmatch;

cout<<"Enter total runs=";

cin>>trun;

cout<<"Enter total wickets=";

cin>>twicket;

}

void putData()

{

cout<<endl<<"Name="<<name;

cout<<endl<<"Age="<<age;

cout<<endl<<"Country="<<country;

cout<<endl<<"Type="<<type;

cout<<endl<<"Total Matches="<<tmatch;

cout<<endl<<"Total Runs="<<trun;

cout<<endl<<"Total Wickets="<<twicket;

}

};

int main()

{

clrscr();

Cricketer c[5];

int i;

cout<<"Enter total cricketers = ";

cin>>n;

for(i=0;i<n;i++)

{

c[i].getData();

}

for(i=0;i<n;i++)

{

c[i].putData();

}

getch();

return 0;

}




No comments:

Post a Comment