C program to store and display records of N employees using structure.

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define N 10
void dummy(float *a)
{
float b=*a; 
//perform some floating access
dummy (&b); 
//calling a floating point function
}
struct employee{
int eid;
char ename[20];
char des[20];
char add[50];
char mobile[14];
char gender;
float salary;
};
void main() {
int i;
struct employee emp[N];
for (i=0;i<N;i++){
clrscr();
printf("Enter %d employee detail:-\n",i+1);
printf("Enter employee identification number\n");
scanf("%d",&emp[i].eid);
getch();
printf("Enter employee name\n");
fflush(stdin);
gets(emp[i].ename);
getch();
printf("Enter employee's designation\n");
fflush(stdin);
gets(emp[i].des);
getch();
printf("Enter address\n");
fflush(stdin);
gets(emp[i].add);
getch();
printf("Enter Mobile no.\n");
gets(emp[i].mobile);
getch();
printf("Enter gender\n");
fflush(stdin);
scanf("%c",&emp[i].gender);
getch();
printf("Enter salary\n");
fflush(stdin);
scanf("%f",&emp[i].salary);
getch();
}
for (i=0;i<N;i++) {
clrscr();
printf("\nDetails of %d employee:-\n",i+1);
printf("Employee id=%d\nEmployee Name=%s\nDesignation=%s\nAddress=%s\nMobile no=%s\n Gender=%c\nSalary=%f .rs\n",emp[i].id,emp[i].ename,emp[i].des,emp[i].add,emp[i].mobileno,emp[i].gender,emp[i].salary);
getch();
}
}

No comments:

Post a Comment