Answer to Question #262203 in C++ for Somya

Question #262203

c++ programming Write a program which reads salaries of 10 employes of an organization. The program will, what the maximum salary is and what the minimum salary is

1
Expert's answer
2021-11-06T20:05:57-0400
#include <iostream>


int main()
{
    double salary[10];
    double min_salary;
    double max_salary;
    for (int i = 1; i < 11; i++) 
    {
        std::cout << "Enter the salary of " << i << " employee: ";
        std::cin >> salary[i - 1];
        if (i == 1)
        {
            min_salary = salary[i - 1];
            max_salary = salary[i - 1];
        }
        if (salary[i - 1] < min_salary)
        {
            min_salary = salary[i - 1];
        }
        if (salary[i - 1] >max_salary)
        {
            max_salary = salary[i - 1];
        }
    }
    std::cout <<" Minimum salary : "<<min_salary<<"\n";
    std::cout << " Maximum salary : " << max_salary << "\n";
    return 0;
}

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