Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- struct date
- {
- int dd,mm,yy;
- };
- struct employee
- {
- char name[20];
- int id;
- struct date doj;
- float salary, HRA, basesal;
- };
- void main()
- {
- int i;
- float temp;
- struct employee emp[5];
- for(i=0;i<5;i++)
- {
- printf("Enter name, employee ID, date of joining (in dd,mm,yy format), HRA and basic salary of Employee #%d", i+1);
- gets(emp[i].name);
- scanf("%d%d%d%d%f%f",&emp[i].id,&emp[i].doj.dd,&emp[i].doj.mm,&emp[i].doj.yy,&emp[i].HRA,&emp[i].basesal);
- }
- for(i=0;i<5;i++)
- emp[i].salary=emp[i].HRA+emp[i].basesal;
- for(i=0;i<5;i++)
- {
- if(emp[i+1].salary>emp[i].salary)
- {
- temp=emp[i].salary;
- emp[i].salary=emp[i+1].salary;
- emp[i+1].salary=temp;
- }
- }
- printf("\n\nSorted details for employees are :\n");
- for(i=0;i<5;i++)
- {
- printf("Employee #%d\nEmployee Name: ",i+1);
- puts(emp[i].name);
- printf("\nEmployee Id: %d\nDate of Joining: %d/%d/%d\nSalary: %f",emp[i].id,emp[i].doj.dd,emp[i].doj.mm,emp[i].doj.yy,emp[i].salary);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement