Write a
menu driven program in C to create a
structure employee having fields empid , empname,salary. Accept the details of n Employees from user and perform the following
operations using function
-
Search by EmpId
- Display Names of Employee having salary is
greater than 10000
#include
<stdio.h>
#include
<conio.h>
void
main()
{
struct
details
{
char name[30];
int eid;
int salary;
}emp[5];
int
n,i,id,ch;
clrscr();
while(1)
{
printf("\n
1:add employee");
printf("\n
2:search employee");
printf("\n
3:Display Names of Employee having salary is greater than 10000 ");
printf("\n
4:exit");
printf("\n
enter the choice");
scanf("\n
%d",&ch);
switch(ch)
{
case 1:
printf("\n enter how many record u
add");
scanf("\n %d",&n);
printf("\n enter employee
record");
for(i=0;i<n;i++)
{
printf("\nEnter name:");
scanf("\n %s",&emp[i].name);
printf("\nEnter id:");
scanf("\n %d",&emp[i].eid);
printf("\nEnter Salary:");
scanf("\n %d",&emp[i].salary);
}
break;
case
2:
printf("\n enter the employee id u
search");
scanf("\n %d",&id);
for(i=0;i<n;i++)
{
if(emp[i].eid==id)
{
printf("\n employee id is
%d",emp[i].eid);
printf("\n employee name is
%s",emp[i].name);
printf("\n employee salary is
%d",emp[i].salary);
}
}
break;
case
3:
for(i=0;i<n;i++)
{
if(emp[i].salary>10000)
{
printf("\n Name of the Employee : %s
",emp[i].name);
printf("\n id of the Employee : %d
",emp[i].eid);
printf("\n Salary of the Employee : %d
",emp[i].salary);
}
}
break;
case
4:exit(0);
}
}
getch();
}
/* output
1:add employee
2:search employee
3:Display Names of Employee having salary is
greater than 10000
4:exit
enter the choice1
enter how many record u add2
enter employee record
Enter name:asha
Enter id:1
Enter
Salary:9950
Enter name:anita
Enter id:2
Enter
Salary:15000
1:add employee
2:search employee
3:Display Names of Employee having salary is
greater than 10000
4:exit
enter the choice2
enter the employee id u search2
employee id is 2
employee name is anita
employee salary is 15000
1:add employee
2:search employee
3:Display Names of Employee having salary is
greater than 10000
4:exit
enter the choice3
Name of the Employee : anita
id of the Employee : 2
Salary of the Employee : 15000
1:add employee
2:search employee
3:Display Names of Employee having salary is
greater than 10000
4:exit
enter the choice */