From 3be00883be6ecc984d0ba5a616842383af4bd357 Mon Sep 17 00:00:00 2001 From: Aadit Agrawal Date: Tue, 10 Sep 2024 10:25:45 +0530 Subject: [PATCH] Add DS/C/Lab/LabEval/eval1.c --- DS/C/Lab/LabEval/eval1.c | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 DS/C/Lab/LabEval/eval1.c diff --git a/DS/C/Lab/LabEval/eval1.c b/DS/C/Lab/LabEval/eval1.c new file mode 100644 index 0000000..cad5691 --- /dev/null +++ b/DS/C/Lab/LabEval/eval1.c @@ -0,0 +1,61 @@ +#include + +// da = 40% of bp, hra = 15% of bp, total salary = bp +hra + da + +typedef struct +{ + char name[50]; + int emp_no; + int emp_pay; + int emp_sal; +} employee; + +void read_employees(employee employees[], int n) +{ + for (int i = 0; i < n; i++) + { + printf("Enter details for employee %d:\n", i + 1); + printf("Name: "); + scanf("%s", employees[i].name); + printf("emp No: "); + scanf("%d", &employees[i].emp_no); + printf("emp basic pay: "); + scanf("%d", &employees[i].emp_pay); + } +} + +void total_salary(employee employees[], int n) +{ + for (int i = 0; i < n; i++) + { + employees[i].emp_sal = ((employees[i].emp_pay) * 1.55); + } +} + +void display_employees(employee employees[], int n) +{ + printf("\nEmployee Information:\n"); + for (int i = 0; i < n; i++) + { + printf("Name: %s, Roll No: %d, Pay: %d, Salary: %d\n", employees[i].name, employees[i].emp_no, employees[i].emp_pay, employees[i].emp_sal); + } +} + +int main() +{ + int n; + + printf("Enter the number of employees: "); + scanf("%d", &n); + + employee employees[n]; + + read_employees(employees, n); + total_salary(employees, n); + + + printf("\nEmployee List:\n"); + display_employees(employees, n); + + return 0; +}