#include <iostream>
using namespace std;
struct employee
{
int emp_code;
string name;
int date_of_joining;
};
int current_date;
int arr[5];
int main()
{
struct employee emp[5];
for(int i=0;i<5;i++){
cout<<"\nEnter details for employee "<<i+1<<endl;
cout<<"\nEnter employee code:";
cin>>emp[i].emp_code;
cout<<"\nEnter employee name:";
cin>>emp[i].name;
cout<<"\nEnter employee date of joining:";
cin>>emp[i].date_of_joining;
cout<<"\nEnter current date: ";
cin>>current_date;
int tenure=current_date-emp[i].date_of_joining;
arr[i]=tenure;
}
cout<<"\nNames of employees whose tenure is 3 or more than 3 years according to the given current date:\n";
for (int i=0;i<5;i++){
if (arr[i]>=3){
cout<<emp[i].name<<endl;
}
}
return 0;
}
Comments
Leave a comment