9.6k views
0 votes
Define the structure. Write a C-program using structure to input staff id, name and the salary of 50 staffs. Display staff id, name and salary of those staff whose salary range from 25 thousand to 40 thousand.



1 Answer

4 votes

Answer:

Step-by-step explanation:

A structure in C language is a user defined data structure. It contains fields or members which are user defined data types or system defined data types. It defines a storage area of a definite size, and describes how each byte in that storage area is to be treated.

#include <stdio.h>

#define N 50

#define NAME_LIMIT 64

struct Employee {

int id;

char name[NAME_LIMIT];

double salary;

} staff_list [N];

main()

{

int i; double salary;

// assume that the staff_list array has been initialized with proper data.

printf("Details of staff with salary between 25,000 and 40,000: \\");

for (i=0; i<N; i++) {

salary = staff_list[i].salary;

if ( salary >= 25000 && salary <=40000)

printf("%d : %s : %d \\", staff_list[i].id, staff_list[i].name, salary);

}

}

User Brian Frost
by
8.6k points