Question 1)Implement this instruction to the code provided. a) Create index_of which will return the index of a given name in the array. This should return -1 if the name is not present. int index_of(string value, string data[ ], int size) Hint: Use similar logic to contains was found. from the video, but return the index where the name b) Create a print_summary procedure that accepts the array and its size, then prints out all of the names, the total length of these names, the index of your name (or -1 if your name is not in the array), and the shortest name. void print_summary(string data[ ] , int size) c) Have create and work with an array of strings- Use a constant for the size (make it 5) Loop to read in the names Call to output the details Hint- No iostream please Written Code- #include”splashkit.h” string read_string(string prompt) { string result; write(prompt) ; result = read_line(); return result; } int read_integer(string prompt ) { string line; line = read_string(prompt); return convert_to_integer(line); } int total_length (string names[], int size) { int result = 0; for(int i = 0; i , size, i ) { string name = names[i]; result = name.length(); } return result; } void print_summary( string data[], int size) { int size; string line; } int main() { #define SIZE 3 string names(SIZE); int i; i = 0; while( i < SIZE ) { names[i] = read_string("Enter a name: "); i ; } for(i = 0; i < SIZE; i ) { write_line(names[i]); } int total; total = total_length(names, SIZE); write_line("Total length: "); write_line(total); return 0; } deselashkit.h strirg read striegistring preapt) string result rite(pronpt) 1 result = read-line(); return result 3 int read integer string pronpt 14 string ire line read stringipreapt) return convert to integerrine): 21 int totsl length Istring nanesI), int size] int result 8; string nere naeIil result nane. LengthO return result 3 vold print sunnary string datel, int size) int 512e; string Lire; 40 int nainl) rdetine SIZE 3 string nones(SIZE i-0; aes[i- read string["Enter à nare: write irea) int totaL total total_length(noves, s12E); write_linel Total lengths urite lineltotall: return 8
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more
Recent Comments