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

C++ Writer program has a declaration in main () to store the string \"The most i

ID: 3684654 • Letter: C

Question

C++

Writer program has a declaration in main () to store the string "The most incomprehensible thing about the world is that it is incomprehensible. - Albert Einstein" into an array named quote. There should be a function called display () that accepts quote in an argument named q and then displays the quote using the pointer notation * (q + i); Modify the display () function written above to alter the address in quote. Always use the expression *q rather than *(q + i) to retrieve the correct element.

Explanation / Answer

(a)

#include <iostream>
#include <string>
using namespace std;
void display(char q[])
{
for(int i=0;q[i]!='';i++)
{
cout<<*(q+i);
}
cout<<' ';
return;
}
int main ()
{
char quote[] = "The most incomprehensible thing about the world is that it is comprehensible, - Albert Einstein";
display(quote);
return 0;
}

(b)

#include <iostream>
#include <string>
using namespace std;
void display(char q[])
{
for(int i=0;q[0]!='';i++)
{
cout<<*(q);
q++;
}
cout<<' ';
return;
}
int main ()
{
char quote[] = "The most incomprehensible thing about the world is that it is comprehensible, - Albert Einstein";
display(quote);
return 0;
}

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