4 questions c codes – www.savvyessaywriters.net

4 questions c codes – www.savvyessaywriters.net

 

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

Savvy Essay Writers

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational