-
Notifications
You must be signed in to change notification settings - Fork 69
/
Employee.c
executable file
·66 lines (56 loc) · 1.57 KB
/
Employee.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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
struct employee
{
char name[100],acc_num[100];
int salary;
}name,acc_num,salary;
void main()
{
struct employee *emp;
int i,n;
int max_sal=0,temp=0;
clock_t start, end;
double cpu_time_used;
start = clock();
printf("The program execution begins at: %ld ms",start);
printf("\n\n Enter the number of employees: ");
scanf("%d",&n);
emp =calloc(n,(sizeof(*emp)));
printf("Enter the informations : \n");
for(i=0;i<n;i++)
{
printf("Enter the employee Name:");
scanf(" %[^\n]",emp[i].name);
printf("Enter the employee's Account Number:");
scanf("%s",&emp[i].acc_num);
printf("Enter the employee's Salary:");
scanf("%d",&emp[i].salary);
printf("\n");
}
max_sal = emp[0].salary;
printf("\nThe details of the employee with highest salary are as follows:\n");
for(i=1;i<n;i++)
{
if(max_sal<emp[i].salary)
{
max_sal = emp[i].salary;
temp=i;
}
}
printf("\n Name of the employee is: ");
printf(" %s",emp[temp].name);
printf("\n Account number is: ");
printf(" %s",emp[temp].acc_num);
printf("\n Salary is: ");
printf("%d",emp[temp].salary);
printf("\n");
end = clock();
printf("\n The program execution ends at: %ld ms",end);
cpu_time_used = (double) (end - start) / CLOCKS_PER_SEC;
printf ("\n Total CPU time taken to run the code in seconds is: %f s", cpu_time_used);
printf("\n");
free(emp);
}