Your task for this assignment is to use the C++ standard library sort() function to sort numbers in an array.
1. Use the sort() routine from the C++ standard library with an array to sort 10 random numbers. The
2. The program displays on one line the original values in the array before the sort begins. After the sort, the program displays on one line the numbers in sorted order, lowest to highest.
3. Your C++ program is named csc231_prog4_yourlastname.cpp. Your C++ program contains comments starting on line 1 containing this information:
a. the ID, section and name of the course
b. your name
c. this file name
d. the program assignment number and due date
e. the program purpose
You are always encouraged to add additional comments throughout the program that your feel might be helpful to the reader of your source code.
4. Submit your C++ program source code file as an attachment to an email message to kbyron@bmcc.cuny.edu using a subject in this form: “csc231_prog4_yourlastname”.
For 66.7% extra credit, add the sort_heap() function to your program. For each sort
Ref: sort(): https://www.geeksforgeeks.org/sort-c-stl/
sort_heap(): https://www.geeksforgeeks.org/sort_heap-function-in-c/
sort_heap(): https://www.cplusplus.com/reference/algorithm/sort_heap/
rand(): https://www.cplusplus.com/reference/cstdlib/rand/
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
- In C++ Create an array of random 10 random numbers. Use the "range-based for loop" (sometimes called "enhanced for loop") to put the values into the array (users choice of number) and use the "range-based for loop" to output the numbers to the console.arrow_forwardattached is sample output needed to complete this C++ assignment. Function definitions needed with the //. please do not use 2d arrays either. Project Description The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. ----------------------------------------------------------------- the code template is as follows ---------------------------------------------- #include<iostream> using namespace std; // Global constants const int ROWS = 3; // The number of rows in the array const int COLS = 3; // The number of columns in the array const int MIN = 1; // The value of the smallest number const int MAX = 9; // The value of the largest number // Function…arrow_forwardWrite C++ code using one dimensional array and for loop to read 4 numbers using cin into an array of size 4. These numbers are 1, -1, 2, 3 After reading these numbers consecutively in the array , your program should provide: How many positive numbers are in the array? (30) What is the average of these positive numbers ? (30) Your results should be displayed using cout. c++ with comments Hint: const int N=4; int arr[N]; int i, count =0; double sum = 0, average=0;arrow_forward
- C++ HELP In this lab, you're going to be working with partially filled arrays that are parallel with each other. That means that the row index in multiple arrays identifies different pieces of data for the same person. This is a simple payroll system that just calculates gross pay given a set of employees, hours worked for the week and hourly rate. Parallel Arrays First, you have to define several arrays in your main program employee names for each employee hourly pay rate for each employee total hours worked for each employee gross pay for each employee You can use a global SIZE of 50 to initialize these arrays Second, you will need a two dimension (2-D) array to record the hours worked each day for an employee. The number of rows for the 2-D array should be the same as the arrays above since each row corresponds to an employee. The number of columns represents days of the week (7 last I looked) Functions Needed In this lab, you must read in the employee names first because this…arrow_forwardUse C++ In a student file, there are names and scores. Find the max score and print out the names of the students with the max score. • You must get a filename as standard input. See two sample outputs on the next page. • The number of students in the file is at most 50. • You need to make two arrays (see the next page). 1. Create a string array with size 50. The array will store the names of the students. 2. Create an integer array with a size of 50. The array will store the scores of the students.arrow_forwardProgramming Language: C++ I really need help with this question and I keep getting repost answers. Please, someone, help with a genuine understanding of the problem. Code two functions to fill an array with the names of every World Series-winning team from 1903 to 2020, then output each World Series winner with the number of times the team won the championship as well as the years they won them. The input file is attached, along with the main function and screenprint. Please note team names that include two words, such as Red Sox, have an underscore in place of the space. This enables you to use the extraction operator with a single string variable. The following resources are included: Here is main. #include <iostream>#include <fstream>#include<string> using namespace std; // Add function declarations and documentation here void fill(string teams[], int size);void findWinner(string teams[], int size); int main(){ const int SIZE = 118;int lastIndex;string team[SIZE];…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education