---
title: "Employees with salary above 10,000"
subject: "Computer Programming"
chapter: 8
key: "semester_1/computer_programming:struct-employee-salary-above-10000"
source: https://www.bctengineer.com/q/semester_1/computer_programming/struct-employee-salary-above-10000
site: BCT Engineering
---

# Employees with salary above 10,000

Computer Programming · Chapter 8: Structures

- Asked in: 2068 Chaitra, 6 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/struct-employee-salary-above-10000
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-8

## Question

Write a program to input name, post and salary of ten employees from main ( ) function and pass to structure type user defined function (arguments of this function should also be structure type). This function returns structure variable which keeps the record of only those employees whose salary is greater than 10,000. This modified record is also displayed from main ( ) function.

## Short answer

A structure 'list' holds an array of 'eemp' and a count. Function 'highPaid' iterates all employees, returns a new list with only those whose salary > 10000. Sample run yields Sita, Gita, Maya, Anit, Suman.

## Answer

**Design.** A structure `emp` holds name, post and salary. A function must receive structures and return a structure, but one `emp` holds only one employee. So a second structure `list` is used which contains an array of 10 `emp` and a counter `count`. The function `highPaid(struct list all)` receives the structure of all employees, copies only those with salary > 10000 into a new `list`, and returns it. `main()` displays the returned (modified) record.

```c
#include <stdio.h>
#define N 10

struct emp {
    char name[30];
    char post[20];
    float salary;
};

struct list {                 /* a structure that holds a group of records */
    struct emp e[N];
    int count;
};

/* structure argument, structure return value */
struct list highPaid(struct list all)
{
    struct list r;
    r.count = 0;
    for (int i = 0; i < all.count; i++)
        if (all.e[i].salary > 10000)
            r.e[r.count++] = all.e[i];
    return r;
}

int main(void)
{
    struct list all, res;
    all.count = N;
    for (int i = 0; i < N; i++) {
        printf("Employee %d (name post salary): ", i + 1);
        scanf("%29s %19s %f", all.e[i].name, all.e[i].post, &all.e[i].salary);
    }
    res = highPaid(all);
    printf("\nEmployees with salary above 10000\n");
    printf("%-10s %-10s %s\n", "Name", "Post", "Salary");
    for (int i = 0; i < res.count; i++)
        printf("%-10s %-10s %.2f\n", res.e[i].name, res.e[i].post, res.e[i].salary);
    return 0;
}
```

**Sample run** (salaries 9000, 45000, 7500, 22000, 10000, 31000, 8000, 90000, 15000, 9500)

Input (entered one after another): `Ram Clerk 9000 Sita Manager 45000 Hari Peon 7500 Gita Officer 22000 Bibek Clerk 10000 Maya Accountant 31000 Kiran Peon 8000 Anita Director 90000 Suman Officer 15000 Rita Clerk 9500`

```text
Employees with salary above 10000
Name       Post       Salary
Sita       Manager    45000.00
Gita       Officer    22000.00
Maya       Accountant 31000.00
Anita      Director   90000.00
Suman      Officer    15000.00
```

The employee with salary exactly 10000 is not included, because the condition is "greater than".

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why is a second structure list used?
   A. To store the salary only
   B. Because emp cannot have a name
   C. To avoid arrays
   D. One emp holds only one employee, but the function must return a group
   Answer: D. list contains an array of emp and a counter. (Key point: Why list)

2. What are the argument and return type of highPaid()?
   A. Both are struct list
   B. Both are int
   C. Argument is int, return is struct emp
   D. Both are float
   Answer: A. A structure is passed in and a structure is returned. (Key point: Function signature)

3. Which employees are copied into the result?
   A. Those with salary >= 10000
   B. Those with salary > 10000
   C. Those with salary < 10000
   D. All employees
   Answer: B. Strict greater than. (Key point: Filter condition)

4. In the sample, why is the employee with salary exactly 10000 excluded?
   A. He was entered wrongly
   B. His name is too long
   C. The condition is 'greater than', not 'greater or equal'
   D. The count was zero
   Answer: C. 10000 is not > 10000. (Key point: Boundary)

5. What does r.count++ do?
   A. Counts input errors
   B. Sums salaries
   C. Resets the list
   D. Tracks how many employees were copied and gives the next free index
   Answer: D. It both stores at the next index and increments the count. (Key point: Counter)

6. Where is the modified record displayed?
   A. In main(), using res.count
   B. Inside highPaid()
   C. In a header file
   D. It is not displayed
   Answer: A. main() loops from 0 to res.count. (Key point: Display)

## Related in Computer Programming

- [Sort employee structures by salary](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astruct-employee-sort-salary) — Computer Programming, chapter 8, asked 2×
- [Switch versus user defined function](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aswitch-vs-user-function) — Computer Programming, chapter 5
- [96 students record; pass marks](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afile-96-students-ioe-txt) — Computer Programming, chapter 10
- [Pass student array; display passed students](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Apass-whole-array-student-info) — Computer Programming, chapter 7
- [Read records until end; show nth record](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afile-worker-nth-record) — Computer Programming, chapter 10, asked 2×
- [Significance of user defined functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Asignificance-user-defined-functions) — Computer Programming, chapter 6

## Related in other subjects

- [Convert user-defined type to basic type](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Auser-to-basic-conversion) — Object Oriented Programming, chapter 5
- [Default arguments and function overloading](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Adefault-args-function-overloading) — Object Oriented Programming, chapter 3, asked 5×
- [File stream; student binary file program](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Afile-stream-student-binary) — Object Oriented Programming, chapter 8
- [3-input XNOR using NOR gates only](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Athree-input-xnor-nor) — Digital Logic, chapter 2
