Program:
/*Program to store employee info, By dsexample.blogspot.com*/
#include <stdio.h>
#include <conio.h>
union employee{
char name[50];
int eid;
float salary;
};
int main(){
union employee e[10];
int i,n;
printf("Enter number of employees ");
scanf("%d",&n);
printf("\n");
for(i=0;i<n;++i)
{
printf("Enter information of employee %d:\n",i+1);
printf("Enter eid: ");
scanf("%d",&e[i].eid);
printf("\nInformation for eid number %d: \n",e[i].eid);
printf("Enter name: ");
scanf("%s",e[i].name); /* while storing string we don't use '&'. */
printf("Name: ");
puts(e[i].name);
printf("\n");
printf("Enter salary: ");
scanf("%f",&e[i].salary);
printf("salary: %f",e[i].salary);
printf("\n======================================\n");
}
return 0;
}
Comments
Post a Comment