Advertisement
Guest User

lolz

a guest
May 27th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1. #include<stdio.h>
  2. struct date
  3. {
  4.     int dd,mm,yy;
  5. };
  6. struct employee
  7. {
  8.     char name[20];
  9.     int id;
  10.     struct date doj;
  11.     float salary, HRA, basesal;
  12. };
  13. void main()
  14. {
  15.     int i;
  16.     float temp;
  17.     struct employee emp[5];
  18.     for(i=0;i<5;i++)
  19.     {
  20.         printf("Enter name, employee ID, date of joining (in dd,mm,yy format), HRA and basic salary of Employee #%d", i+1);
  21.         gets(emp[i].name);
  22.         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);
  23.     }
  24.     for(i=0;i<5;i++)
  25.         emp[i].salary=emp[i].HRA+emp[i].basesal;
  26.     for(i=0;i<5;i++)
  27.     {
  28.         if(emp[i+1].salary>emp[i].salary)
  29.         {
  30.             temp=emp[i].salary;
  31.             emp[i].salary=emp[i+1].salary;
  32.             emp[i+1].salary=temp;
  33.         }
  34.     }
  35.     printf("\n\nSorted details for employees are :\n");
  36.     for(i=0;i<5;i++)
  37.     {
  38.         printf("Employee #%d\nEmployee Name: ",i+1);
  39.         puts(emp[i].name);
  40.         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);
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement