Consider a scenario where you need to manage records of employees in a company. Create aprogram in C that utilizes structures to handle employee information. The program shouldperform the following tasks:a. Define a structure named Employee with the following attributes:Employee ID (integer)Employee Name (string)Department (string)Salary (float)b. Create an array of structures to store information for a maximum of 5 employees.c. Display the information of the employees.
Question
Consider a scenario where you need to manage records of employees in a company. Create aprogram in C that utilizes structures to handle employee information. The program shouldperform the following tasks:a. Define a structure named Employee with the following attributes:Employee ID (integer)Employee Name (string)Department (string)Salary (float)b. Create an array of structures to store information for a maximum of 5 employees.c. Display the information of the employees.
Solution
To create a program that manages records of employees in a company, follow these steps:
-
Define a structure named "Employee" with the following attributes:
- Employee ID (integer)
- Employee Name (string)
- Department (string)
- Salary (float)
-
Create an array of structures to store information for a maximum of 5 employees. For example:
struct Employee employees[5]; -
Prompt the user to input the information for each employee and store it in the array. You can use a loop to iterate through the array and prompt for each attribute. For example:
for (int i = 0; i < 5; i++) { printf("Enter details for Employee %d:\n", i+1); printf("Employee ID: "); scanf("%d", &employees[i].employeeID); printf("Employee Name: "); scanf("%s", employees[i].employeeName); printf("Department: "); scanf("%s", employees[i].department); printf("Salary: "); scanf("%f", &employees[i].salary); } -
Display the information of the employees by iterating through the array and printing each attribute. For example:
printf("Employee Information:\n"); for (int i = 0; i < 5; i++) { printf("Employee %d:\n", i+1); printf("Employee ID: %d\n", employees[i].employeeID); printf("Employee Name: %s\n", employees[i].employeeName); printf("Department: %s\n", employees[i].department); printf("Salary: %.2f\n", employees[i].salary); }
That's it! You have now created a program in C that utilizes structures to handle employee information and performs the tasks mentioned in the scenario.
Similar Questions
Design a structure in C to represent an employee's information, including their name, employee ID, department, and salary. Additionally, write a program that allows users to input employee data, display employee information, and update an employee's salary. write a code for demonstrating the implementation of the structure and program functionalities.input and output Enter employee details:Enter employee name: John DoeEnter employee ID: 101Enter department: SalesEnter salary: 50000Employee Information:Name: John Employee ID: 101 Department:Sales Salary: 50000.00Enter new salary: 55000Salary updated successfully.Updated Employee Information:Name: JohnEmployee ID: 101Department: SalesSalary: 55000.00
Write a C program to store the information of employees in a company using structures. Each employee should have the following details:Employee code (integer)Employee name (string)Salary (float)Department number (integer)The program should allow the user to input the number of employees (n) and then input the details of each employee. i.Display the employee name with the maximum salary.ii. Display the average salary of all employees in the company.Test Case:3 // number of employees101 //Enter employee code:John Doe // Enter employee name:50000.00 // Enter salary:1 // Enter department number:102Jane Smith60000.001103Suresh Raina55000.002Output:Jane Smith55000.00 // avg of all employees salary
Write a program to create a bank customer information using array of structures, nested structures and functions.First structure should hold the following information: Customer personal details: Name, Gender, Account Number, DOB; Second structure should hold the following information: Customer account details: Type of account, opening balance, closing balance
Write a programme in C++ which read and print employee information with department and pf information using hierarchical inheritance
Problem Statement:Your university wants you to create a management system that will store employee data in the following hierarchy. Create the necessary classes that represent the following diagram: The attributes for each of the classes are provided in the diagram for your reference.In addition to the Staff, Management, and the Teacher classes, you need to create the Education class which should be associated only with the Teacher and the Management.You have to create a menu based application to store and display the data.The input options shall be 1 for Teacher, 2 for Management, and 3 for Admin.For each of these options you display the type of data being provided as input and request the user to enter the relevant information. For qualification, you shall provide them with options from 1-4 and once all the data has been provided, you shall then display the given information in a formatted output.Once the data has been displayed, you should then print "Staff being deleted..." in the Staff class's destructor.Please refer to the input and output section for more details.Input format :The input consists of an integer choice, followed by data related to a specific employee type (Teacher, Management, or Admin) based on the given choice.For Teacher:choice = 1Employee code (string)Employee name (string)Educational qualification (integer): (1: - Undergraduate, 2 - Graduate, 3 - Masters Degree, 4 - PhD)Subject (string)For Management:choice = 2Employee code (string)Employee name (string)Educational qualification (integer): (1: - Undergraduate, 2 - Graduate, 3 - Masters Degree, 4 - PhD)Management Grade (float)For Admin:choice = 3Employee code (string)Employee name (string)Department (string)Output format :The output displays the user information based on the user input, along with the "Staff being deleted..." message from the destructor.A new line space is given after the last line of the output.Refer to the sample output for the formatting specifications.Code constraints :The educational qualification should only be within the given range of 1 to 4The choice will be an integer between 1 and 3 (inclusive).Employee code, employee name, subject, and department will be strings with a maximum length of 20 characters.Educational qualification will be an integer (1, 2, 3, or 4).Management Grade should be an integer.Sample test cases :Input 1 :1ABC3343HarryPotter2WizardryOutput 1 :TEACHER The given information:Employee code: ABC3343Employee name: HarryPotterEducational Qualification: GraduateSubject: WizardryStaff being deleted...Staff being deleted...Staff being deleted...Input 2 :2KLD34RonWeasley34Output 2 :MANAGEMENT The given information:Employee code: KLD34Employee name: RonWeasleyEducational Qualification: Masters DegreeManagement Grade: 4Staff being deleted...Staff being deleted...Staff being deleted...Input 3 :3CMS34343HermioneCompsciOutput 3 :ADMIN The given information:Employee code: CMS34343Employee name: HermioneDepartment: CompsciStaff being deleted...Staff being deleted...Staff being deleted...Input 4 :4Output 4 :Invalid choiceStaff being deleted...Staff being deleted...Staff being deleted...Input 5 :2KLD34RonWeasley6532Output 5 :MANAGEMENTInvalid Educational Qualification. Try one more time.Invalid Educational Qualification. Try one more time. The given information:Employee code: KLD34Employee name: RonWeasleyEducational Qualification: Masters DegreeManagement Grade: 2Staff being deleted...Staff being deleted...Staff being deleted...Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.