GU.Structure.9. Define a structure employee with members employee name, basic pay, dearness allowance, house rent, net salary. Declare an array of 5 employees. Write a function which calculates the net salary of employees and prints all employee details in descending order of their net salary.

//Program Prepared by Chirag Jadav, FYBCA-2018-19

Define a structure employee with members employee name, basic pay, dearness allowance, house rent, net salary. Declare an array of 5 employees. Write a function which calculates the net salary of employees and prints all employee details in descending order of their net salary.

#include<stdio.h>
#include<conio.h>

struct emp
{
char name[99];
float basic,DA,HR,netsal;
}E[5]; //E[5]=5 Employee details..
void main()
{
int i;
clrscr();

for(i=0;i<5;i++)
{
printf("\nEnter %d employee name : ",i+1);
scanf("%s",E[i].name);

printf("\nEnter %d employee Basic salary : ",i+1);
scanf("%f",&E[i].basic);

printf("\nEnter %d employee Dearness Allowance : ",i+1);
scanf("%f",&E[i].DA);

printf("\nEnter %d employee House Rent : ",i+1);
scanf("%f",&E[i].HR);

E[i].netsal=E[i].basic + E[i].DA + E[i].HR;

printf("\n-------------------------------------\n");

}

for(i=5;i>0;i--)
{
printf("\n%d employee name : %s",i,E[i].name);

printf("\n%d employee Basic salary : %f",i,E[i].basic);

printf("\n%d employee Dearness Allowance : %f",i,E[i].DA);

printf("\n%d employee House Rent : %f",i,E[i].HR);

printf("\n%d employee netsalary is %f",i,E[i].netsal);

printf("\n-------------------------------------\n");

}
getch();
}

void dummy()
{
float x,*y;
y=&x;
x=*y;
}

No comments:

Post a Comment