C Program For Employee Information Using Nested Structure

/*C program to read and print employee's record using structure*/
#include <stdio.h>
/*structure declaration*/
struct employee{
    char    name[30];
    int     empId;
    float   salary;
int main()
    /*declare structure variable*/
    struct employee emp;
    /*read employee details*/
    printf("\nEnter details :\n");
    printf("Name ?:");          gets(emp.name);
    printf("ID ?:");            scanf("%d",&emp.empId);
    printf("Salary ?:");        scanf("%f",&emp.salary);
    /*print employee details*/
    printf("\nEntered detail is:");
    printf("Name: %s"   ,emp.name);
    printf("Id: %d"     ,emp.empId);
    printf("Salary: %f\n",emp.salary);
    return 0;


Enter details :
Name ?:Mike
ID ?:1120
Salary ?:76543
Entered detail is:
Name: Mike
Id: 1120
Salary: 76543.000000
Sharing Is Caring

Leave a Comment