The need:
This is a simple program to calculate total salary from basic. This program was given to me as assignment in lab.
The code:
--------------------------------------------
#include<stdio.h>
float total_sal(float );
main()
{
int i,k;
char z;
struct employee
{
char name[30],ID[15],Dep[40];
float basic,DA,HRA,total_salary;
} emp[10];
printf("Enter the number of employees you want to calculate data for..");
scanf("%d",&k);
for(i=0;i",i+1);
gets (emp[i].name);
printf("Enter ID of employee%d\t=>",i+1);
gets (emp[i].ID);
printf("Enter Department of employee%d\t=>",i+1);
gets (emp[i].Dep);
printf("Enter Basic-Salary of employee%d\t=>",i+1);
scanf("%f",&emp[i].basic);
emp[i].DA=0.4*emp[i].basic;
emp[i].HRA=0.25*emp[i].basic;
emp[i].total_salary=total_sal(emp[i].basic);
}
for(i=0;i ");
puts (emp[i].name);
printf("ID\t\t => ");
puts (emp[i].ID);
printf("Department\t => ");
puts (emp[i].Dep);
printf("BASIC\t\t => %.2f\n",emp[i].basic);
printf("DA\t\t => ");
printf("%.2f",emp[i].DA);
printf("\nHRA\t\t => ");
printf("%.2f",emp[i].HRA);
printf("\nTotal Salary\t => ");
printf("%.2f\n",emp[i].total_salary);
}
}
float total_sal(float bs)
{
float da=0.4*bs;
float hra=0.25*bs;
float total=bs+da+hra;
return(total);
} --------------------------------------------Remarks:
1. This is only a sample program. There may be other allowances and benefits associated depending upon the employee of different types.
No comments:
Post a Comment
feel free to ask your doubts... if any
you can post your doubts on
www.facebook.com/programsimply