Answer to Question #264791 in C++ for Yusra

Question #264791

Write a program that allow you to write the salaries of 10 employees. The program will tell you tha maximum and the minimun salary

1
Expert's answer
2021-11-12T00:55:10-0500

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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS