Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function for the following prototype: void addLetterS( const char orig[]

ID: 3762070 • Letter: W

Question

Write a function for the following prototype:

void addLetterS( const char orig[], char plural[])

The function will copy the "orig" character array into the character array "plural" adding an s at the end.
For example if the orig array contained "hello" then the plural array will result in "hellos"
Use the following sample driver:

char word[10];
addLetterS( school , word); // copy word into school and add an 's' to the end
cout << word << endl;      // will output the contents of word i.e. "schools"

HINT - Use a loop incrementing i until orig[i] equals ''...when the loop stops move 's' into that position and then
move '' into the following position.

Explanation / Answer

void addLetterS(const char orig[],char plural[]){

int i;

for(i = 0; orig[i] != ''; i++)

plural[i] = orig[i];

plural[i++] = 's';

plural[i] = '';

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote