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...
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...
Language: c++ works in visual basic Write a program that uses an array of nested structs...
Language: c++ works in visual basic Write a program that uses an array of nested structs to store the addresses for your store’s customers.  Each customer has a name and two addresses: home address and business address.  Each address has a street, city, state, and zip code. Requirements: 1. Data structure a. Define an Address struct with street, city, state and zip fields b. Define a Customer struct with lastNm and firstNm fields, plus homeAddr and busAddr fields...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT