2. Complete the following programs so that the main program can exchange the con
ID: 3752936 • Letter: 2
Question
2. Complete the following programs so that the main program can exchange the contests of two c-strings
(a) #include <iostream>
using namespace std;
void exchange(char ** , char **);
int main()
{
char * s1 = "Hello";
char * s2 = "Bye Bye";
//call function exchange, one line of code goes here
cout << "s1 = " << s1 << endl; //"Bye Bye" should be displayed
cout << "s2 = " << s2 << endl; // "Hello" should be displayed
return 0;
}
void exchange(char **p1, char **p2)
//Implement function exchange
// your code goes here
Explanation / Answer
#include using namespace std; void exchange(char**, char**); int main() { char* s1 = "Hello"; char* s2 = "Bye Bye"; //call function exchange, one line of code goes here exchange(&s1, &s2); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.