//Displaying the detail of all employees in the order of their salary.  
            #include< stdio.h >
            #include< stdlib.h >
            struct employee
            {
	            char name[20];
	            int id;
	            int salary;
            };
            void main()
            {
	              struct employee e[5],temp;
	              int i,j;
	              FILE *fp;
	              fp = fopen("employee.txt", "r+b");
	              fread(&e, sizeof(e), 5, fp);
	              for(i=0;i<5;i++)
	              {
	                for(j=0;j<5;j++)
	                   {
                       if(e[i].salary < e[j].salary)
                            {
                             temp = e[i];
                             e[i] = e[j];
                             e[j] = temp;
                            }
	                   }
	              }
                 printf("Required record of employee in order of their salary are \n");
	              for (i = 0; i<5; i++)
	              {
		              printf("%s %d %d\n", e[i].name, e[i].id, e[i].salary);
	              }
            
	              fclose(fp);
            } 
            
            
            Output: 
            
            Required record of employee in order of their salary are 
            Satis 1 20000 
            Utshab 2 30000 
            Nimesh 3 40000 
            Safal 4 50000 
            Biraj 5 60000