A program to declare a structure employee with the following data members:
a) emp_no                     integer
b) name character          array
c) basic_salary             float
Your program should accept the data of 10 employees and then print the data of those employees only whose net salary is above Rs.10000/-. Where net salary is calculated as:
basic_salary + incentive - deductions
incentive is 50% of the basic salary
deductions are 10% of basic salary + Rs.200/- extra for each employee

 

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

struct employee
{
int emp_no;
char name[30];
float basic_salary;
};

void main()
{
clrscr();

employee emp[10];

double incentive[2],deduction[2],net_salary[2];
int i;

for(i=0;i<10;i++)
{
cout<<"Enter employee no.: ";
cin>>emp[i].emp_no;
cout<<"Enter employee name: ";
gets(emp[i].name);
cout<<"Enter Basic Salary: ";
cin>>emp[i].basic_salary;
incentive[i]=.5*emp[i].basic_salary;
deduction[i]=.1*emp[i].basic_salary+200;
net_salary[i]= emp[i].basic_salary + incentive[i] - deduction[i];
cout<<endl;
}

cout<<"\n************************************************\n\n";
cout<<"Employees whose net salary is above Rs.10000/-:\n\n";
for(i=0;i<10;i++)
{
if(net_salary[i]>10000)
{
cout<<"Employee no.: "<<emp[i].emp_no<<endl;
cout<<"Employee name: ";
puts(emp[i].name);
cout<<"Basic Salary: "<<emp[i].basic_salary<<endl;
cout<<endl;
}
}

cout<<"\n************************************************\n";

getch();

}

 

 

< Back