hello : share me for these question??pls>>

this is q?
write a program that reads information about 20 employees and store it in a array of strucures, the structure of each employee should contain : name 9does not exceed 20 characters), ID (int) , salary (double) between 200 and 4000 and address which belongs to one of the following {A,B,C,D,E} the progrem should then output the following :

1- the average of employee salaries.

2- the names of employees whose salaries are above the average.

I waiting you..
you want a whole working program written to you?
hello man>>
i don't mean the all because i have the answer but i need to be sure and this is the program :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "iostream.h"
struct employee {
 char name[20];
 int ID;
 double salary;
 char address;
};
void main(){
 employee A[20];
 int sum=0;
 int avg;
 for (int i=0;i<20;i++)
  cout<<"Employee :"<<"i+1"<<endl;
  cout<<"Name";
 cin>>A[i].name;
 cout<<"ID";
  cin>>A[i].ID;
 cout<<"salatry:";
 cin>>A[i].salary;
}


only i need help to complete the answer if not have a mistake>>>
thats what i wanted, the code which you have written.. so that someone can help you to correct that code.. :)

the program looks fine..
after the for loop you can calculate the average and salary above average.

one suggestion:

in the loop you can ask the user if he wants to quit.. so that he dont have to input for all the 20 values..
rest of your program is good.
to optimize and not calculate the sum of salary you can add the salaries during the input only like this:
1
2
3
4
5
6
7
8
9
int sum = 0;
for (...)
{
//your code...

cin>>A[i].salary;
sum += A[i].salary;
}
int average = sum / 20;
thank u very much man for helping me ;but where is the 2 section in this q ?????

i write this code :
1
2
3
4
for (int i=0;i<20;i++)
If (A[i].salary>average)
Cout<< A[i].names<<endl;
}


thats right or not???
thats correct.
Topic archived. No new replies allowed.