Question: q16) CONSIDER THE FOLLOWING CODE: void Question() { string a = edcba; string b = fghij; cout < < Before: < < endl; for (int
q16)
CONSIDER THE FOLLOWING CODE: void Question() { string a = "edcba"; string b = "fghij"; cout << "Before:" << endl; for (int i = 0; i < a.length(); i++) cout << a[i] << " "; cout << endl; for (int i = 0; i < a.length(); i++) cout << b[i] << " "; MoveThem(a, b, a.length()); cout << endl; cout << "After:" << endl; for (int i = 0; i < a.length(); i++) cout << a[i] << " "; cout << endl; for (int i = 0; i < a.length(); i++) cout << b[i] << " "; } ///////////////////////////////////////////////////////// void MoveThem(string &x, string &y, int n) { string temp; for (int i = 0; i < n; i++) { temp = x[i]; x[i] = y[i]; y[i] = temp[0]; } }
Select one:
a. Before: e d c b a f g h i j After: j i h g f g e d c b a
b. Before: e d c b a f g h i j After: f g h i j e d c b a
c. Before: e d c b a f g h i j After: f g h i j a b c d e
d. Before: e d c b a f g h i j After: e d c b a f g h i j
please explain how you get the answer. Thank you
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
