Reading name, post and salary of 10 different employees and displaying those records whose salary is greater than 10000 using user defined function c++

Reading name, post and salary of 10 different employees and displaying those records whose salary is greater than 10000 using user defined function c++


#include <iostream>

#include <string>


struct Employee {

    std::string name;

    std::string post;

    double salary;

};


// Function to display records with salary greater than 10000

void displayHighSalaryEmployees(Employee employees[], int size) {

    std::cout << "Employees with salary greater than 10000:\n";

    for (int i = 0; i < size; ++i) {

        if (employees[i].salary > 10000) {

            std::cout << "Name: " << employees[i].name << "\n";

            std::cout << "Post: " << employees[i].post << "\n";

            std::cout << "Salary: " << employees[i].salary << "\n\n";

        }

    }

}


int main() {

    const int numEmployees = 10;

    Employee employees[numEmployees];


    // Input employee details

    for (int i = 0; i < numEmployees; ++i) {

        std::cout << "Enter details for employee " << i + 1 << ":\n";

        std::cout << "Name: ";

        std::cin >> employees[i].name;

        std::cout << "Post: ";

        std::cin >> employees[i].post;

        std::cout << "Salary: ";

        std::cin >> employees[i].salary;

    }


    // Display records for employees with salary greater than 10000

    displayHighSalaryEmployees(emplo

yees, numEmployees);


    return 0;

}




Comments

Popular posts from this blog

Multipath inheritance :There are 2 Ways to Avoid this Ambiguity: