Week #4 - Structures
#include<stdio.h>
struct employee
int empno;
char empname[20];
float salary;
};
void main()
struct employee e[20],temp;
int i,j,n;
printf("\nEnter no. of Employees : ");
scanf("%d",&n);
for(i=0;i<n;i++)
printf("\n Enter the Employee Number: ");
scanf("%d",&e[i].empno);
printf("\n Enter the Employee Name: ");
scanf("%s",&e[i].empname);
printf("\n Enter the Employee Salary: ");
scanf("%f",&e[i].salary);
for(i=0;i<=n-1;i++)
for(j=0;j<=n-1;j++)
if(e[j].salary<e[j+1].salary)
{
temp=e[j];
e[j]=e[j+1];
e[j+1]=temp;
printf("\nThe Employee Sorted List bassed on salary\n");
printf("\n*******************************************\n");
printf("\nEmp.No\tEmp.Name\tSalary\n");
for(j=0;j<n;j++)
printf("%d\t%s\t%f\n",e[j].empno,e[j].empname,e[j].salary);
getch();