Write a
20 30 4 20 30 30 −1 |
Then the output should be:
Number of 4's: 1 Number of 20's: 2 Number of 30's: 3 |
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Digital Fundamentals (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Programarrow_forwardTouch Convert 1. Create a program using a vector that stores in two vectors: the hours worked by 3 employees, their hourly pay rates, gross total pay, and net total pay (after the deduction of income tax just use 20%) for each employee. Expected output: enter hourly... Hours worked by employee #1: 23 Hourly pay rate for employee #1: 20 Hours worked by employee #2: 24 Hourly pay rate for employee #2: 25 Hours worked by employee #3: 35 Hourly pay rate for employee #3: 23.99 Here is the gross pay and Employee #1: $460.00 Employee #2: $600.00 Employee #3: $805.00 2. Write a function named timesFour that accepts an argument. When a function is net pay for each employee: $368.00 $480.00 S644.00 the proc of its areument multiplied by 4. Expectedarrow_forwardWrite a program that initialises a vector with the following string values: "what" "book" "is" "that" "you" "are" "reading". Display the contents of the vector on the screen to the user as a question and read in the name of the book the user is reading (you can decide what it will be). Have the program add the name of the book to the vector, word by word. For example, if I am reading "How to learn C++", the program should add the words, "How" "to" "learn" "C++", one by one to the vector. Display the new vector. Remember to plan your program!arrow_forward
- Integer numin is read from input. Given the integer vector yearlySalary with the size of numin, write a for loop to initialize the first half of yearlySalary with the remaining integers read from input. Ex: If the input is 6 116 132 134 then the output is: 116 132 134 0 0 0 Note: The vector size is always even. 5 int main() { 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21} vector yearlySalary; unsigned int i; int numIn; cin >> numIn; // Creates a vector of size numIn and initialize all values to 0 yearlySalary.resize(numIn); /* Your code goes here */ for (i = 0; i < yearlySalary.size(); ++i) { cout << yearlySalary.at (i) << " "; } return 0;arrow_forwardmatlabarrow_forwardCourse: Introduction to MATLAB programming Student Number: 180505005arrow_forward
- Integer numElements is read from input. Given the integer vector yearlyMiles with the size of numElements, write a for loop that sets sumBonus to the total bonus miles. Miles above 300 contain bonus miles. Ex: If the input is 4 36 350 353 64 then the output is: sumBonus: 103 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24} int numElements; int sumBonus; cin >> numElements; // Creates a vector of size numElements and initialize all values to 0 yearlyMiles.resize (numElements); for (i = 0; i > yearlyMiles.at(i); } * Your code goes here */ cout << "sumBonus: " << sumBonus << endl; return 0;arrow_forwarda vector can be either a row vector or a .column vector no O yes cannot say O can be yes or no Oarrow_forwardC++ languagearrow_forward
- The program initializes a vector with an assigned capacity and a random number for each element. The program counts the histogram of all of the contents of the vector ranging from 1 to 5 and displays it on the screen. The program is also getting the sum of all of the vectors and displays it afterwards. I just displayed the equivalent sum of the histogram and as well as the sum that i was able to get from the vectors for double checking if they match so as to know the program is correct. Your task is to improve the performance of the program, as we can see that there are things that we can do in concurrent here namely (counting of histogram and getting the sum of the vector). Convert the program to support multithreading in counting the histogram and getting the sum of the vector. Use thread, locks, mutex to improve the performance of the program. #include <iostream> #include <vector> #include <chrono> #include <cstdlib> using namespace std; int main(){…arrow_forward6. A three-dimensional vector has the form: A = (x, y, z) can be represented as: given the vectors: Example: Their sum is:Example: struct VECTOR { double x; double y; double z; }; A = ( a, b, c ) (5, 6, 2) and B = ( d, e, f ) (3, 1,9) A + B = ( a + d, b + e, c + f ) (5 + 3, 6 + 1, 2 + 9) = (8, 7,11)A B = a x d + b x e + c x f Their scalar product is:(result is a scalar) example: 5 x 3 + 6 x 1 + 2 x 9 = 39 Write the complete definition code for the functions: a. calc_sum computes and returns the sum of two vectors b. scalar_prod computes and returns the scalar product of two vectorsarrow_forwardComputer Science IN MATLAB Write a function CalFunc.m that can receive multiple math function as input arguments in the form of function handles. This function has one output argument which is the number of input arguments. This function creates a 1x100 vector with values between 0 and 10 as the x values, plots all function handles in a single plot with a proper legend. If the function is called without any input argument, the function will ask the user to enter an anonymous function for plotting. Your program should work as below: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