3
/*Program to declare a class staff having data members as name and department. Accept data for 3 staffs and display name of the staff that are in the IT department*/ #include<iostream.h> #include<conio.h> #include<string.h> class staff { public: char name[20],dept[20]; void accept() { cout<<"\n\n\t\tEnter name : "; cin>>name; cout<<"\n\n\t\tEnter department : "; cin>>dept; } void display() { cout<<"\n\n\t\tName : "<<name<<endl; // cout<<"\n\n\t\tDept : "<<dept<<endl; }

Pratik Bakane C++

Embed Size (px)

Citation preview

Page 1: Pratik Bakane C++

/*Program to declare a class staff having data members as name and

department. Accept data for 3 staffs and display name of the staff that

are in the IT department*/

#include<iostream.h>

#include<conio.h>

#include<string.h>

class staff

{

public:

char name[20],dept[20];

void accept()

{

cout<<"\n\n\t\tEnter name : ";

cin>>name;

cout<<"\n\n\t\tEnter department : ";

cin>>dept;

}

void display()

{

cout<<"\n\n\t\tName : "<<name<<endl;

// cout<<"\n\n\t\tDept : "<<dept<<endl;

}

Page 2: Pratik Bakane C++

};

void main()

{

int i;

clrscr();

staff s[3];

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

s[i].accept();

cout<<"********Member in IT department***************"<<endl;

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

{

if(strcmp(s[i].dept,"IT")==0)

s[i].display();

}

getch();

}

Page 3: Pratik Bakane C++

OUTPUT: