01 Jul 4 questions c++ codes
Question Description
1) Write a c++ program that contains the following functions
a) A function that takes in an integer array of any size, and fills up the array with values taken from the user. (Your function should work for any size array, and should be tested with at least 3 arrays of different sizes)
b) Do the same as a) above, but get the values from a file instead. (Create a file that has input for at least 3 arrays of different sizes).
c) A function that takes in an array of any size, and returns the sum of all multiples of 5 in the array.
d) A function that takes in an array of any size and an integer key m. It should return the mth smallest element in the array. (m cannot be larger than the size of the array, and your array should be unsorted).
For example for an array containing 3 2 4 8 9 6, and m is 2, it should return the 2nd smallest number in the array which is 3
e) A function that takes in an array of any size and a key, and returns the number of passes it takes to find the key in the array or 0 if it’s not in the array. Use Binary Search
f) A function that takes in an array of any size and prints the content 4 per line. (Test this function with at least 3 arrays of different sizes)
Optional Question (Practice)
Write the definition of a function that takes in any array of any size, and an integer key, and returns the smallest value closest to they key if it is in the array, returns 0 otherwise (Use Binary Search)
Example
6, 11, 15, 24 29 35 49 61 75 83. is contained in an array, with a key of 49, the smallest value closest to 49 is 35, and your function returns that.
2) Write a C++ program that reads from a file the last name of an election candidate and the number of votes that they received, you program would then determine what percentage of vote each candidate received and the winner of the election. Use the concept of parallel arrays. Your program should contain the following functions
a) A function to read in the data from the file into the appropriate data structure
b) A function to calculate each candidates percentage of vote earned
c) A function to print out each candidate’s name, number of votes and percentage of total vote earned (Output should be formatted to look like the file, with a new header for vote percent)
d) A function that returns the name of the election winner.
Use appropriate function calls to test your program. Below is the content of the file. ignore the first line containing the headers if it makes it easier to write
Candidate Number of Votes
Lannister 350000
Stark 310000
Targaryen 397000
Baratheon 275000
Martell 280000
Greyjoy 205000
Mormont 415000
Tully 30000
(Feel free to adjust the numbers in the file)
there is two more questios in the attachments
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.