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
#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;
}
Comments
Leave a comment