Question: Please use C++ struct Employee { char name[20]; int empID; double salary; }; A variable of type Employee is then declared below. Employee empArr[100]; Write

Please use C++

struct Employee

{

char name[20];

int empID;

double salary;

};

A variable of type Employee is then declared below.

Employee empArr[100];

Write a function called highestPay that takes an array of Employees like the one above and prints out the name of the employee with the highest salary. Write a fragment of code to call this function with the array empArr. Show the definition of the function and the function call assuming it is called from the main.

Is my answer below correct?

void highestPay(Employee arr)

{

double amount;

double highestAmount = 0.0;

for (int i = 0; i < 100; i++)

{

if (arr[i].salary > highestAmount)

{

amount = highestAmount;

}

}

for( int i = 0, int j = 0; i < 100, j < 20; i++, j++)

{

if (arr[i].salary == amount)

{

cout << arr[i].name[j];

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!