In: Computer Science
Write a C++ program that uses array to store the salaries of 10 employees working in a small firm. The program should take average of the salaries and the max and min salaries being paid to the employees
C++ program :-
#include <iostream>
using namespace std;
int main() {
int arr[10];
int sum=0;
int max,min;
cout<<"ENter the salary of 10 employees :"<<endl;
for(int i = 0; i<10; i++)
{
cin>>arr[i];
sum=sum+arr[i];
if(i==0)
{
min=arr[i];
max=arr[i];
}
else
{
if(arr[i]>max)
max=arr[i];
if(arr[i]<min)
min=arr[i];
}
}
double avg = (double)sum/10.0;
cout<<"The average of the salaries :
"<<avg<<endl;
cout<<"The minimum of the salaries :
"<<min<<endl;
cout<<"The maximum of the salaries :
"<<max<<endl;
}
Output :-