In: Computer Science
Can someone solve these two questions for an intro c++ course?
1.
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
    char twostrings[] = "Hello! CS103L!";
    char* p1;
    char* p2;
    //fill in the code required to print out Hello! and CS103L! on different lines
    //Hint: modify one character in the original string and set p1 and p2 correctly
    //Do not make any copies or new strings or arrays. You only need to modify the original array.
    
    //
    cout << p1 << endl;
    cout << p2 << endl;
}
2.
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
    string column1[5];
    string column2[5]
    //use the getline() function (not cin.getline()) to read in 5 lines from cin into column1
    
    //now read 5 lines from cin into column2
        
    //Now write a for loop that will print out five lines with the two columns next to each other separated by a tab character
    //try using string concatenation instead of multiple << operators 
}
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
char twostrings[] = "Hello! CS103L!";
char* p1;
char* p2;
//fill in the code required to print out Hello! and CS103L! on
different lines
//Hint: modify one character in the original string and set p1 and
p2 correctly
//Do not make any copies or new strings or arrays. You only need to
modify the original array.
  
//modifying one character
twostrings[6]='\0';
//setting pointers
p1 = twostrings;
p2 = twostrings+7;
  
cout << p1 << endl;
cout << p2 << endl;
}
output:
Hello!
CS103L!
Process exited normally.
Press any key to continue . . .
2)
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
string column1[5];
string column2[5];
//use the getline() function (not cin.getline()) to read in 5 lines
from cin into column1
for(int i=0;i<5;i++)
   getline(cin,column1[i]);
  
//now read 5 lines from cin into column2
for(int i=0;i<5;i++)
   getline(cin,column2[i]);
  
//Now write a for loop that will print out five lines with the two
columns next to each other separated by a tab character
//try using string concatenation instead of multiple <<
operators
   for(int i=0;i<5;i++)
  
cout<<column1[i]+"\t"+column2[i]<<endl;
return 0;
}