3
That’s the question of the program:
Make a program, using the function below, that displays the highest salary of each department of a company and how many employees earn the department’s highest salary. For each department, the program should read the department code and the amount of employees, and for each employee, registration and salary. End of reading departments: department code = 0. Perform the function of a department to process the employees of a department. This function should receive as a parameter the amount of department employees, read the data of each employee, find out the department’s highest salary and how many employees earn this higher salary, storing them in the variables whose addresses are provided in the function call.
I performed the following code:
#include <stdio.h>
struct funcionario
{
char nome[20];
float salario;
char matricula[10];
};
void um_departamento(struct funcionario *func, int *numfunc){
int i, maior,cont=0;
maior = func[0].salario;;
for (i = 0; i < *numfunc; i++){
if (func[i].salario > maior){
maior = func[i].salario;
cont++;
}
}
printf("%d %d", maior,cont);
}
int main(){
int departamento, i, functot, coddep, depzin,num=20;
struct funcionario funz[num];
printf ("Digite o departamento e seu codigo");
scanf ("%d %d", &departamento, &coddep);
for (i = 0; i < departamento; i++){
dep (functot);
print ("Digite a matricula e o salário");
scanf ("%f%f", &funz[i].salario, &funz[i].matricula);
}
um_departamento(funz, &num);
return 0;
}
How can I fix it? Thank you very much.
about memory junk search a little about the command fflush(stdin); but and basically put this command before reading data.
– mateus santana