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 function to compute the magnitude f

write a function to compute the magnitude F and direction angle of a two-dimensional force F by using two components of the force fx,fy as its parameters,returning F and using the reference to pass theta value .

  Define inheritance and polymorphism

Inheritance and Polymorphism, The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java.

  Elements of a list begin numbering

For this program you will add and test 2 new member functions to the IntSLList class posted on the website.Assuming that the positions of elements of a list begin numbering at 1 and continue to the end of the list, you will insert a new node with i..

  Design an employee class

Design an Employee class that has fields for the following pieces of information: Employee Name and Employee Number

  Declare two character arrays

Write a C program for Code warrior, to declare two character arrays called list1 and list2. Initialize list1 with your first and last name. Write the main code to copy list1 to list2.

  Perimeter of a trapezoid

Write a function in c that will return the perimeter of a trapezoid

  Relate the features with the real life scenarios

Explain any three features that must be implemented by the application that will be created by WebSoft Solutions Pvt. Ltd. Support your answer with suitable examples. Relate the features with the real life scenarios.

  Problem regarding the database systems

To develop a database for the given case study by drawing the EER diagram-To apply the normalization rules to the data structures and hence to show the UNF, INF, 2NF, and 3NF relations of the given scenario-To create and manipulate database.

  Write c program that requests name of any cartoon character

Write a C program that requests the name of any cartoon character from the user, then does the following with that name (use printf for each): Displays it enclosed in double quotes.

  Compute for the monthly billing of their customers

An electric company wants to compute for the monthly billing of their customers. the company charges P2.50 per kwh and utility tax of 3% of the current bill shall be added.

  Returns a count of the steps through the sort

Please write a c++ implimentation that returns a count of the steps through the sort. (do not worry about updating count, I will rewrite that segemnt. I need help with writing the shell sort.

  A list of toppings should be shown on the screen as a menu

Write a menu-driven C++ program that allows a user to select from the following items: Pizza, Cheeseburger, and Hot Dog. Pizza should be represented by the integer value 1. Cheeseburger should be represented by the integer value 2.

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