Sunday, 24 April 2022

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.

 


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

struct employee
{
    char name[20];
    long b_pay,da,hr,net_sal;
}e[5];

void main()
{
    int i;
    clrscr();

    for(i=0; i<5; i++)
    {
        printf("\nenter %d employee name: ",i+1);
        scanf("%s",e[i].name);
        printf("enter %d employee basic pay: ",i+1);
        scanf("%ld",&e[i].b_pay);
        printf("enter %d employee dearness allowence: ",i+1);
        scanf("%ld",&e[i].da);
        printf("enter %d employee house rent: ",i+1);
        scanf("%ld",&e[i].hr);

        e[i].net_sal = e[i].b_pay + e[i].da + e[i].hr;
    }
    for(i=0; i<5; i++)
    {
        printf("\n\n%d employee name: %s",i+1,e[i].name);
        printf("\n%d employee basic pay: %ld",i+1,e[i].b_pay);
        printf("\n%d employee dearness allowence: %ld",i+1,e[i].da);
        printf("\n%d employee house rent: %ld",i+1,e[i].hr);
        printf("\n%d employee net salary: %ld",i+1,e[i].net_sal);
    }
    getch();
}

No comments:

Post a Comment

python programs

1. sum of two number