Add DS/C/Lab/LabEval/eval1.c
This commit is contained in:
parent
8de2a08e83
commit
3be00883be
61
DS/C/Lab/LabEval/eval1.c
Normal file
61
DS/C/Lab/LabEval/eval1.c
Normal file
@ -0,0 +1,61 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user