Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # How to know the average without disclosing the salaries?

• 0
• 0
• 0
• 0
• 0
• 0
• 0
• 0
• 311
Comment on it

Suppose we want to find the average salary of three employee(A,B,C) without disclosing there individual salary.In order to do this see the following algorithm:

ALGORITHM :

1. First A will add a random number to it's salary and then tell the total sum to B.
2. B will add its salary to the sum told by A and tell the new sum to C.
3. C will also add its salary to the sum told by B and tell the new sum to A.
4. A will now subtract its random number from the sum.
5. Now we have a new number which is the total of all three employee salary.
6. We will take average by dividing total buy 3.

PROGRAM :

``````int main(){
int a=10,b=20,c=30,avg=0;
int x=1;
//printf("Enter the first number:::");
//scanf("%d",&a);
//printf("Enter the second number:::");
//scanf("%d",&b);
//printf("Enter the first number:::");
//scanf("%d",&c);

a=x+a;
b=a+b;
c=b+c;

a=c-x;
avg=a/3;
printf("total sum ::: %d",a);
printf("\naverage ::: %d",avg);

return 1;
}``````

OUTPUT :

``````total sum ::: 60
average ::: 20``````

## 0 Comment(s)

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General