61 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
#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;
 | 
						|
}
 |