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 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).  
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...
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]
Write a program in C to perform the following: Generates an array of 10 double random...
Write a program in C to perform the following: Generates an array of 10 double random values between 1.0 and 100.0 – assume these are prices for 10 items that a store sells Generates an array of 10 integer random values between 0 and 200 – assume that these are the number of items/units (first array) sold Generate another array called “itemSale” which would contain the total sale for each item. Calculate the total sale for this store and display...
Write a C program that asks the user to enter 15 integer numbers and then store them in the array.
Write a C program that asks the user to enter 15 integer numbers and then store them in the array. Then, the program will find the second largest element in array and its index without sorting the array. For example, In this array {-55,-2,1, 2, -3, 0, 5, 9, 13, 1, 4, 3, 2, 1, 0}, the second largest element is 9 [found at index 7].
Write a program that uses an array for time and temperature. The program should contain an...
Write a program that uses an array for time and temperature. The program should contain an array with 24 elements, each of which is holding a temperature for a single hour. Your program should have a function that lists all of the temperatures that are held in the array. Temperatures should be listed to console with one entry per line. Your program should have a function that lists a single temperature entry. You should ask the user for a number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT