Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- int main()
- {
- int codSetor, mat, setores = 0, funcs = 0, funcsSetor, setorMaiorSalario = 0;
- float sal, totSal = 0, totSalSetor = 0, maiorSalSetor, maiorSalario = 0;
- char nome[20], nomeMaiorSalario[20];
- printf("Digite o codigo do setor:\n");
- scanf("%d", &codSetor);
- while(codSetor > 0)
- {
- printf("Digite o numero da matricula:\n");
- scanf("%d", &mat);
- funcsSetor = 0;
- totSalSetor = 0;
- maiorSalSetor = 0;
- setores++;
- while(mat > 0)
- {
- printf("Digite o salario do funcionario:\n");
- scanf("%f", &sal);
- totSalSetor += sal;
- printf("Digite o nome do funcionario:\n");
- fflush(stdin);
- fgets(nome, 20, stdin);
- if(sal > maiorSalSetor)
- {
- maiorSalSetor = sal;
- strcpy(nomeMaiorSalario, nome);
- }
- funcsSetor++;
- printf("Digite o numero da matricula:\n");
- scanf("%d", &mat);
- }
- funcs += funcsSetor;
- if(totSalSetor > maiorSalario)
- {
- maiorSalario = totSalSetor;
- setorMaiorSalario = codSetor;
- }
- totSal += totSalSetor;
- printf("Trabalham %d funcionarios nesse setor\n", funcsSetor);
- printf("A empresa paga um total de R$%.2f de salario nesse setor\n", totSalSetor);
- printf("O funcionario que mais ganha nesse setor se chama %s\n", nomeMaiorSalario);
- printf("Digite o codigo do setor:\n");
- scanf("%d", &codSetor);
- }
- if(setores == 0)
- printf("Nenhum setor registrado\n");
- else
- {
- printf("%d setores na empresa\n", setores);
- printf("%d funcionarios na empresa\n", funcs);
- printf("R$%.2f pago de salario pela empresa\n", totSal);
- printf("O setor de codigo %d gasta mais em salarios\n", setorMaiorSalario);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement