C program to store and display n employees info using Structure

C program to display info of n employees using Structure


C program to display information of n employees using Structure.

same structure program for student details 

Program:

/*Program to store employee info, By SlashMyCode.com*/
#include <stdio.h>
#include <conio.h>
struct employee{
    char name[50];
    int eid;
    float salary;
};
int main(){
    struct employee e[10];
    int i,n;

    printf("Enter number of employees ");
    scanf("%d",&n);

    for(i=0;i<n;++i)
    {
        printf("Enter information of employee %d:\n\n",i+1);
        printf("Enter eid: ");
        scanf("%d",&e[i].eid);
        printf("\nFor eid number %d\n",e[i].eid);
        printf("Enter name: ");
        scanf("%s",e[i].name); /* while storing string we don't use '&'. */
        printf("Enter salary: ");
        scanf("%f",&e[i].salary);
        printf("\n");
    }
    printf("==========================================\n");
    printf("Displaying information of all employees:\n");
    for(i=0;i<n;++i)
    {
     printf("\nInformation for eid number %d:\n",e[i].eid);
     printf("Name: ");
     puts(e[i].name);
     printf("salary: %f",e[i].salary);
     printf("\n\n");
    }
/*Program to store employee info, By SlashMyCode.com*/
   return 0;

}

Output:
output of C program to display info of n employees using Structure





No comments:

Post a Comment

Feel free to ask us any question regarding this post