-
Notifications
You must be signed in to change notification settings - Fork 0
/
pro.c
85 lines (72 loc) · 2.27 KB
/
pro.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<stdio.h>
#include<string.h>
#define MAX_EMPLOYEE 100
//define a structure for employees
typedef struct{
int id;
char name[50];
float salary;
}Employee;
void addemployee(Employee employees[],int *count);
void displayemployee(Employee employees[],int count);
//void updateemployee(Employee employees[],int count);
//void deleteemployee(Employee employees[],int *count);
int main(){
Employee employees[MAX_EMPLOYEE];
int count=0,choice;
while (1){
printf("\n Employee managment system\n");
printf("1. add employe.\n");
printf("2. Display Employees.\n");
printf("3. Update employee.\n");
printf("4. Delete employee.\n");
printf("5. Exit.\n ");
printf(" Enter your choice : ");
scanf("%d",&choice);
switch (choice){
case 1 :
addemployee(employees,&count);
break;
case 2 :
displayemployee(employees,count);
break;
// case 3 :
//updateemployee(employees,count);
// break;
//case 4 :
//deleteemployee(employees,&count);
//break;
case 5 :
printf("EXIT");
return 0;
default :
printf("Enter the valid number from the option's !") ;
}
}
return 0;
}
void addemployee(Employee employees[],int *count){
if(*count >= MAX_EMPLOYEE){
printf("maximum space limit ,no more data can be added .");
return ;
}
printf("\nENTER the detail of employee :\n");
printf("Enter id : ");
scanf("%d",&employees[*count].id);
printf("\nEnter name : ");
scanf("%s",&employees[*count].name);
printf("\nEnter salary : ");
scanf("%f",employees[*count].salary);
(*count)++;
printf("\n Employee added succesfully . ");
}
void displayemployee(Employee employees[],int count){
if(count == 0 ){
printf("No detail to display . ");
return ;
}
printf("\n i'd \t\t Name \t\t Salary ");
for(int i=0 ; i<=count ; i++){
printf("\n %d\t\t %s \t\t %f ",employees[i].id,employees[i].name,employees[i].salary);
}
}