Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
641 views
in Computer by (69.2k points)

Define a structure for an employee of an organization having employee code, name, address, phone number and number of dependents. Assume that “allEmployees” is an array of employees in ascending order on the employee code. Write a function to display the details of an employee given its employee code. 

1 Answer

0 votes
by (70.0k points)
selected by
 
Best answer

A structure for an employee and a function to display the details of an employee:

struct employee

{

int emp_code;

char emp_name[30];

char emp_address[50];

char emp_ph_num[10]; int no_of_dep;

allEmployees[100],b;

void display()

{

int ctr=0;

fp=fopen("employee.c","r");

rewind(fp)

while(fread(&allEmployees,sizeof(allEmployees[i]),1

fp)==1)

{

ctr++;

clrscr();

heading();

printf("\n\n\n\

Following are the details :-");

printf("\n\n\tRecord #%d",ctr);

printf("\n\n\t\tCode : %d",allEmployees[i].emp_code)

printf("\n\n\t\tName : %s",allEmployees[i].emp_name)

printf("\n\n\t\tAddress : %s",allEmployees[i].emp_address)

printf("\n\n\t\tPhoneNumber:%s"allEmployees[i].emp_ph_num

printf("\n\n\t\tNumber.Dependents

%s",allEmployees[i].no_of_dep);

printf("\n\n\n\n\t\tPlease Press Enter...");

getch();

}

}  

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...