Write a second function called countelements

Assignment Help C/C++ Programming
Reference no: EM131310293

COMPUTER APPLICATIONS DIVISION

Assignment: C++ PROGRAMMING

STL Vector

For this assignment, you will be starting with an example program that demonstrates the use of a STL vector. In addition to this, you may need to look up how to generate random numbers.

Your end project will enter 100 random numbers (range 0-9) into the vector. Then, ask for a number to search for, and count how many there are in your group. When you complete the assignment, I want you to answer a couple questions about random numbers. Here are the details.

Start with the STL_Vector example. Use the rand function to generate random numbers between 0 and 9. If you need help generating random numbers see:

https://www.cplusplus.com/reference/cstdlib/rand/. Set up a for loop that puts 100 of these random number into a STL Vector. Change the printVector function in the example to print out all of the contents of your vector. Now you can see the contents of the vector which is the 100 random numbers you generated.

Write a second function called countElements. The definition will be:

int countElements( const std::vector<unsigned int>& MyVector, unsigned int SearchValue );

You will pass into countElements your vector (by reference), and the number you are looking for.

Your function will use a for loop with an iterator (like the one used in printVector) to compare each Vector element to the SearchValue. Count up the number of matches and return the total count.

You have an example executable program to mimic.

Questions to Answer in your ReadMe.txt file.

Are your numbers truly random? Run your program a number of times. Do you get the same numbers each time you run it? If not, can you make them random?

Put your findings in your ReadMe.txt file.

Reference no: EM131310293

Questions Cloud

Ummarize your course project and share any difficulties : Walmart is one of the largest companies in America; it has solidified its position as the biggest retailer in America and the world over with several branches all around the globe. Walmart prides itself in affordable products for everyday American..
How planning and operation flow differs for mto and mts firm : Discuss how the planning/coordination and operation flow differs for MTO and MTS firms.- Compare and contrast the role of planning/coordination and operations in improving firm competitiveness.
Principles in a business environment : You are to complete a minimum 500-word essay in which you describe resource pooling architecture and how you would apply these principles in a business environment.
Generate a second message that produces the same hash value : A network consists of n hosts. Assuming that cryptographic keys are distributed on a per-hostpair basis, compute how many different keys are required.
Write a second function called countelements : C0­227 C++ PROGRAMMING- Write a second function called countElements. The definition will be: int countElements( const std::vector & MyVector, unsigned int SearchValue );
Discuss the driver and role of the inventory deployment : Discuss why it is important to coordinate the arrival of procurement shipments with the dispatching of customer shipments.
Write a program that creates three identical arrays : Write program that create three identical array, list1, list2, and list3 of 5000 elements. Write a function, removeAt, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, index).
Role of crm system in enhancing the firms competitiveness : Discuss the rationale and risks associated with using a common forecast to drive the firms planning/coordination flow.
Principles in a business environment : You are to complete a minimum 500-word essay in which you describe resource pooling architecture and how you would apply these principles in a business environment.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a cpp program for magic number

Ask the user to enter a "magic number," which is an integer between 0 and 9, inclusive. Then, ask a user to enter 10 integers between 0 and 9, inclusive. If a user enters an integer outside of that range, therefore invalid, notify the user of the ..

  Interactive natural cubic spline

My project depends on previous homework because of that I posted all the questions to be clear, but the main project that I need help with is the homework3

  Perform ticket bookings for various flights

The development team of SoftSols Inc. analyzes the source code of the existing software and notes the following observations: The software contains a private class, named bookTickets, that contains the methods used to perform ticket bookings for va..

  Write a function named caesardecipher

Write a function named caesarDecipher that accepts a key value (the Caesar shift value) as its first command-line parameter, and a string (the ciphertext) for its second parameter. Your caesarDecipher function should look like this:

  Using visual c++ and your opengl configured environment

Using Visual C++ and your OpenGL configured environment, write an application that uses OpenGL Raster transformations to draw a triangle of your choice of size, location and color, and then rotate that triangle by 90 degrees and scale it by a fact..

  Implement the tronomino tiling algorithm

Implement the tronomino tiling algorithm,  our program should take an arbitrary input positive integer  k  in the Linux command line and generate a 2 k  * 2 k  board.

  Allows the user to enter the coefficients for a system

Create a graphical (not text-based) Visual C++ program that allows the user to enter the coefficients for a system of four equations with four unknowns. Include a button that when clicked, will solve the system of equations and display the results in..

  Define the operations using peano arithmetic

Write five tests for each using numbers larger than 100 and verify using natZint and intZnat that your numbers work the same way as the usual natural numbers.

  Develop data structures - chord system

Develop data structures which are suitable to hold required information for each peer in a CHORD system. Note that index nodes can hold local information only

  Write a cgi script that will parse a program

Show that Merge Sort has an O(n lg n) running time by timing the code on the computer - Overview of the program for loop

  How you would use a character array

Arrays include multiple data types and can include characters. Understanding that you can use characters in an array, give an example of how you would use a character array and what data could be stored in this array. See page 351 for an example.

  The second argument to the function is the string

The function fnUserBinaryInputX has 2 input arguments, each is a string. The first string is the "prompt" string displayed to the user when asked to enter a string. The second argument to the function is the string to compare the user entered stri..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd