c structure and union program to read and print an employee records using structure

c structure and union program to read and print an employee records using structure

/*The C program to read and print employee's record using the structure*/
#include
/*This is structure declaration*/
struct employee{
char e_name[30];
int e_Id;
float e_salary;
};
int main()
{
/*declare structure variable*/
struct employee emp1;
/*read employee details*/
printf("\nEnter Employee details :\n");
printf("Employee Name :");
gets(emp1.e_name);
printf("Employee ID :");
scanf("%d",&emp1.e_Id);
printf("Employee Salary :");
scanf("%f",&emp1.e_salary);
/*print employee details*/
printf("\nEntered detail is:");
printf("Employee Name: %s" ,emp1.e_name);
printf("Employee Id: %d" ,emp1.e_Id);
printf("Employee Salary: %f\n",emp1.e_salary);
return 0;
}

Output

c structure and union program to read and print an employee records using structure