Write a program that allow you to write the salaries of 10 employees. The program will tell you tha maximum and the minimun salary
Source code
#include <iostream>
using namespace std;
int main()
{
int n=10;
int salary[n];
cout<<"\nEnter salaries for "<<n<<" employees:\n";
for(int i=0;i<n;i++){
cin>>salary[i];
}
int min=salary[0];
int max=salary[0];
for(int i=0;i<n;i++){
if(salary[i]>max){
max=salary[i];
}
if(salary[i]<min){
min=salary[i];
}
}
cout<<"\nThe maximum salary = "<<max;
cout<<"\nThe minimum salary = "<<min;
return 0;
}
Output
Comments
Leave a comment