Emploee Salary Calculation using Structures
Get wages of n employees and calculate the basic pay, HRA and Net pay of each employee.
Program or Solution
#include<stdio.h>
struct employee
{
char name[50];
int wages;
float days,basic_pay,hra,net_pay;
};
int main()
{
int n,i;
scanf("%d",&n);
struct employee e[n];
for(i=0;i<n;i++)
{
scanf("%s",e[i].name);
scanf("%d %f",&e[i].wages,&e[i].days);
e[i].basic_pay=e[i].wages*e[i].days;
e[i].hra=e[i].basic_pay * 0.12;
e[i].net_pay=e[i].hra+e[i].basic_pay;
}
for(i=0;i<n;i++)
{
printf("Name: %s\nBasicPay: %f\nHRA:%f\nNetPay:%f\n",e[i].name,e[i].basic_pay,e[i].hra,e[i].net_pay);
}
}
Program Explanation
create a structure variable as array and store the employee details.Comments
coming Soon
coming Soon