Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. Write a function called shortestString, which takes an array of string with the array capacity and returns the index of the shortest string in

A. Write a function called shortestString, which takes an array of string with the array capacity and returns the index of the shortest string in the array.

B.Write a function called triangle that takes the size of the triangle as its parameter, prints a triangle with alphabets A-Z, after Z go back to A Test with the following 2 main functions int main(){ string x[4] = {"This", "is", "one", "example"}; int index_of_shortest = shortestString(x, 4); cout << x[index_of_shortest] << endl; //prints:is triangle(5); /*The above function prints following: A BC DEF GHIJ KLMNO */ return 0; } int main(){ string array[6] = {"This ", "is", " another", " ", "one", "!!!"}; int index_of_shortest = shortestString(x, 6); cout << x[index_of_shortest] << endl; //prints: triangle(7); /*The above function prints following: A BC DEF GHIJ KLMNO PQRSTU VWXYZAB */ return 0; }

C. Explain the output of the following program as comments in the program.

int main(int argc, char* argv[]) { int i = 0; cout << i - 1 << endl; //i is 0, 0 - 1 evaluates to -1, print out this value, variable i hasn't changed. cout << i-- << endl; // cout << argc << i << endl; // i = 0; string st = argv[++i + 1]; // st += "CI"; // cout << argv[i] << endl; // // i is 1, argv[1] is the second word of this program's argument given at the time when running this program, in this case, QC cout << argv[i][i] << endl; // cout << st << endl; // cout << st[i++] << endl; // cout << i << endl; // cout << st[i]++ << endl; // cout << st << endl; // cout << st.substr(0,2) << endl; // st.insert(st.size() - 2, " "); // cout << st.substr(st.size()-3) << endl; // while (i++ < 10) {} // cout << i << endl; // return 0; } To run this program, ./a.out QC CS

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Explain the various methods of job evaluation

Answered: 1 week ago

Question

Differentiate Personnel Management and Human Resource Management

Answered: 1 week ago

Question

Describe the functions of Human resource management

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago