Question

In: Computer Science

Write a C++ program that uses array to store the salaries of 10 employees working in...

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

Solutions

Expert Solution

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 :-


Related Solutions

IN JAVA Write a program that uses a two-dimensional array to store the highest and lowest...
IN JAVA Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. Prompt the user for 12 months of highest and lowest.   Write two methods : one to calculate and return the average high and one to calculate and return the average low of the year. Your program should output all the values in the array and then output the average high and the average low. im trying to...
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for...
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. Prompt the user for 12 months of highest and lowest.   Write two methods : one to calculate and return the average high and one to calculate and return the average low of the year. These methods MUST be your original code.   Your program should output all the values in the array and then output the average high and the...
Write a program that uses a two dimensional array to store the highest and lowest temperatures...
Write a program that uses a two dimensional array to store the highest and lowest temperatures for each month of the calendar year. The temperatures will be entered at the keyboard. This program must output the average high, average low, and highest and lowest temperatures of the year. The results will be printed on the console. The program must include the following methods: A method named inputTempForMonth whose purpose is to input a high and a low temperature for a...
Write a C program for this:ABC company decides to raise the salaries of its employees according...
Write a C program for this:ABC company decides to raise the salaries of its employees according to the following table: employee_status         years_of_service                    percent_raise                                Full-time                   less than 5 years                        4.0                   Full-time                   5 years or more                           5.0                   Part-time                   less than 5 years                         2.5                   Part-time                   5 years or more                           3.0 If employee_status value is ā€˜Fā€™, the employee is full-time; if it is ā€˜Pā€™, he or she is a part-time employee. Write a...
In C++, write a program that uses array to calculate the factorial of a reasonable large...
In C++, write a program that uses array to calculate the factorial of a reasonable large number (say, up to 2,000).
In C++. Write a program that uses array to calculate the factorial of a reasonable large...
In C++. Write a program that uses array to calculate the factorial of a reasonable large number (say, up to 2,000).  
Using JAVA Write a program that uses a 2-D array to store the highest and lowest...
Using JAVA Write a program that uses a 2-D array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and highest and lowest temperatures of the year. Your program must consist of the following methods with their appropriate parameters: a.) getData: This method reads and stores the data in the 2-D array. b.) averageHigh: This method calculates and returns the average high temperature of the year. c.)...
Program in C: Write a program in C that reorders the elements in an array in...
Program in C: Write a program in C that reorders the elements in an array in ascending order from least to greatest. The array is {1,4,3,2,6,5,9,8,7,10}. You must use a swap function and a main function in the code. (Hint: Use void swap and swap)
Write a C program to Declare an integer array of size 10 with values initialized as...
Write a C program to Declare an integer array of size 10 with values initialized as follows. int intArray[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Compute each item of a new array of same size derived from the above array by: adding first item (intArray[0]) of the array with 3rd, 2nd with 4th, 3rd with 5th and so on. For the last-but-one item intArray[8], add it with first item and for the last item (intArray[9])...
Write a C program to show sum of 10 elements of array and show the average....
Write a C program to show sum of 10 elements of array and show the average. [10]
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT