There are 50 employees in an organization Create a “struct” called “employee” to
ID: 3615514 • Letter: T
Question
- There are 50 employees in an organization
- Create a “struct” called “employee” tohold the following employee records
-
- Employee ID (0 to 49)
- Employee Salary (2500 to 3500)
- Employee Status (F or P)
- struct will create a user-defined data-type for employeeinformation
- All the 50 employee’s record should have the samedata-type of “struct employee”
-
- Hint: Create a employee array of type“employee”
- Randomly fill the salary and status values for all employees(using looping)
- Ask user to enter a number between 0 to 49, say X
- Print the employee X’s information
Explanation / Answer
using namespace std;struct employee { int id; int salary; char status; }; int main() { employee array[50]; for(short v=0;v<50;v++) { cout<<"Please enter the Id of Employee"; cin>>array[v].id; cout<<"Please enter the Salary of Employee"; cin>>array[v].salary; cout<<"Please enter the status of Employee"; cin>>array[v].status; } int x; cout<<"Enter a number to display his Record"; cin>>x; if(x<50) { cout<<" Employee ID:"<<array[x].id; cout<<" EmployeeSalaray:"<<array[x].salary; cout<<" Employee Status:"<<array[x].status; } else cout<<"Employee is Not exist for this number"; system("pause"); return 0; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.