Embed presentation
Downloaded 14 times
![/*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<<"nnttEnter name : ";
cin>>name;
cout<<"nnttEnter department : ";
cin>>dept;
}
void display()
{
cout<<"nnttName : "<<name<<endl;
// cout<<"nnttDept : "<<dept<<endl;
}](https://image.slidesharecdn.com/pratik5-140528074547-phpapp01/85/Pratik-Bakane-C-1-320.jpg)
![};
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();
}](https://image.slidesharecdn.com/pratik5-140528074547-phpapp01/85/Pratik-Bakane-C-2-320.jpg)

The document is a C++ program that defines a 'staff' class with attributes for name and department. It accepts data for three staff members and displays the names of those in the IT department. However, there are issues in the implementation, such as the loop iterating beyond the defined array size.
![/*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<<"nnttEnter name : ";
cin>>name;
cout<<"nnttEnter department : ";
cin>>dept;
}
void display()
{
cout<<"nnttName : "<<name<<endl;
// cout<<"nnttDept : "<<dept<<endl;
}](https://image.slidesharecdn.com/pratik5-140528074547-phpapp01/85/Pratik-Bakane-C-1-320.jpg)
![};
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();
}](https://image.slidesharecdn.com/pratik5-140528074547-phpapp01/85/Pratik-Bakane-C-2-320.jpg)
