Anda di halaman 1dari 3

#include<iostream.

h>
#include<conio.h>
#include<stdio.h>
struct emp
{
int no;
char name[30];
char ph[10];
char address[50];
int year;
float bsal,tsal,hra,da,ta;
};
emp ob[5];
void display(int ,int);
void input()
{
int i;
for(i=0;i<5;i++)
{
cout<<"enter no \n";
cin>>ob[i].no;
cout<<"enter name \n";
gets(ob[i].name);
cout<<"enter phone no \n";
gets(ob[i].ph);
cout<<"enter address \n";
gets(ob[i].address);
cout<<"enter year \n";
cin>>ob[i].year;
cout<<"enter bsal \n";
cin>>ob[i].bsal;
}
}
void calc()
{
int i;
if(ob[i].year<3)
{
for(i=0;i<5;i++)
{
ob[i].ta=10.0/100*ob[i].bsal;
ob[i].hra=15.0/100*ob[i].bsal;
ob[i].da=20.0/100*ob[i].bsal;
ob[i].tsal=ob[i].ta+ob[i].hra+ob[i].da;
}
}
else if(ob[i].year>3)
{
for(i=0;i<5;i++)
{
ob[i].ta=15.0/100*ob[i].bsal;
ob[i].hra=20.0/100*ob[i].bsal;
ob[i].da=25.0/100*ob[i].bsal;
ob[i].tsal=ob[i].ta+ob[i].hra+ob[i].da;
}
}
}
void count()
{
int i,cnt=0,lcnt=0;

for(i=0;i<5;i++)
{
if(ob[i].tsal>5000)
cnt++;
else
lcnt++;
}
cout<<"employees recieving the amt more than 5000:"<<cnt<<"\n";
cout<<"employees recieving the amt less than 5000:"<<lcnt<<"\n";
}
void cmp()
{
int i,max1,max2,loc1,loc2;
if(ob[0].tsal>ob[1].tsal)
{
max1=ob[0].tsal;
loc1=0;
max2=ob[1].tsal;
loc2=1;
}
else if(ob[1].tsal>ob[0].tsal)
{
max1=ob[1].tsal;
loc1=1;
max2=ob[0].tsal;
loc2=0;
}
for(i=2;i<5;i++)
{
if(ob[i].tsal>max1)
{
max2=max1;
loc2=loc1;
max1=ob[i].tsal;
loc1=i;
}
else if(ob[i].tsal<max1 && ob[i].tsal>max2)
{
max2=ob[i].tsal;
loc2=i;
}
}
display(loc1,loc2);
}
void display(int loc1,int loc2)
{
int i;
for(i=0;i<5;i++)
{
cout<<ob[i].no<<"\n";
cout<<ob[i].name<<"\n";
cout<<ob[i].address<<"\n";
cout<<ob[i].ph<<"\n";
cout<<ob[i].year<<"\n";
cout<<ob[i].tsal<<"\n";
}
cout<<"the maximum salary holder are:\n";
cout<<ob[loc1].no<<" ";
cout<<ob[loc1].name<<" ";
cout<<ob[loc1].tsal<<" ";

cout<<ob[loc2].no<<" ";
cout<<ob[loc2].name<<" ";
cout<<ob[loc2].tsal<<" ";
}
void main()
{
clrscr();
cout<<"enter the datas of employees";
input();
calc();
count();
cmp();
getch();
}

Anda mungkin juga menyukai