Problem: Write a C program to read and print employee details using structure.

To store multiple employee details we will use an array of structures. Each element in the array will represent a single employee.

Each Structure i.e. Employee contains:

  • Name
  • Id
  • Salary

In our program, we will read the inputs for each employee from the user, and then output all employee details by iterating through the array using the ‘for’ loop.

C Program to Read and Print Employee Details

Output of Program

C Program for Employee Details using Structure

If you didn’t understand any part of the code then do comment below.

This Post Has 13 Comments

  1. Balaji

    What is the difference between array and structure array

    1. Adarsh Kumar

      They both are similar. The difference is the type of data in the array. When we declare int array[10], we mean to store integers into the array and in case of Employee array[10], we mean to store structure objects into the array.

  2. Balaji

    Why you have write the Employee; after defining structure

    1. Adarsh Kumar

      Any name you put at the end of the structure declaration along with typedef at the beginning is used to rename the structure. In our case, we have renamed the structure as Employee. so that we can address the structure in main funtion using just Employee instead of struct Employee.

  3. Shaik Amin

    Write a program to read the details of ā€˜Nā€™ employees (ID, Name, Salary) and display the details of those employees whose salary is above Rs.10,000/-.
    Can any one write this program.?

    1. Adarsh Kumar

      The logic of your problem can be easily solved using the above program. Just include if(employees[i].salary> 10000) indide the loop which prints the employee details.

  4. Rekha

    1. Write a Menu Driven C program to create an employee database using structure and perform following operations: (I) Accept Employee Record (II) Display All Employees Records (III) Search Employee Record by name and Display (IV) Search Employee Record by Employee ID and Display (V) Update Employee Record (Note: Employee record will have following fields Employee ID, Employee Name, Employee Department, Employee Salary)

    can i pls get a code for this

  5. Ritik vani

    How to add date of joining of the employee in the program

    1. Adarsh Kumar

      Add another char array (string) to store the date of joining.

  6. Jayashree

    In case of storing 20 employees,we need to change ?

    1. Adarsh Kumar

      change the value of n

  7. Amira osama

    if I want to print details of one employee by his id what should I do?

    1. Adarsh Kumar

      If you want to print an employee by his id use any of the search algorithms such as linear search or binary search to search an employee in the employee array. If found then output his details.

Leave a Reply

twenty − five =