212k views
0 votes
• Input a list of employee names and salaries stored in parallel arrays. The salaries should be floating point numbers in increments of 100. For example, a salary of $36,000 should be input as 36.0 and a salary of $85,900 should be input as 85.9. Find the mean (average) salary and display the names and salaries of employees who earn within a range of $5,000 from the mean. In other words, if the mean salary is $45,000, all employees who earn between $40,000 and $50,000 should be displayed.

1 Answer

6 votes

Answer:

The program was implemented using C language

Step-by-step explanation:

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#include<string.h>

int main()

{

//DECLARE THE PARALLEL ARRAYS FOR SALARIES AND NAME

float salaries[10];

char *emp_Names[10];

int EMPn,k1,k2;

float tot_SAL=0,meanSAL;

//GET THE NO OF EMPLOYEES

printf("ENTR THE NO OF EMPLOYEES:");

scanf("%d",&EMPn);

printf("eNTER EMPLOYEE NAME AND SALARY:");

//GET EMPLOYEE NAME AND SALARY

for(k1=0;k1<EMPn;k1++)

{

scanf("%f%s",&salaries[k1],emp_Names[k1]);

}

for(k1=0;k1<EMPn;k1++)

{

tot_SAL+=(salaries[k1]*1000);

}

//FIND THE MEAN

meanSAL=tot_SAL/EMPn;

//PRINT THE EMPLOYEE NAME AND SALARY WHOSE SALARY IS WITHIN HTE AVERAGE

printf("EMPLOYEES WHOSE SALARY IS IN THE RANGE OF MEAN:");

for(k1=0;k1<EMPn;k1++)

{

if((salaries[k1]*1000)>=(meanSAL-5000)&&(salaries[k1]*1000)<=(meanSAL+5000))

{

printf("NAME: %s sALARY:%f",emp_Names[k1],salaries[k1]*1000);

}

}

getch();

return 0;

}

User Leon Timmermans
by
5.9k points