C PROGRAMMING PLEASE HELP Which of the following properly de

C++ PROGRAMMING. PLEASE HELP

Which of the following properly define(s) the C-string containing \"Hello\" ? Explain why the Incorrect option(s) do not work properly. a) char stringVar[10] = \"Hello\"; b) char stringVar[10] = {H\', \'e\', \"I\", \"I\", \'o\'}; c) char stringVar[10] = {\'H\', \'e\', \"I\", \"I\", \'o\', \'\\0\'}; d) char stringVar[7] = \"Hello\"; e) char stringVar[] = \"Hello\"; f) char stringVar[5] = \"Hello\"; In the following code fragment: char s [20], i[25], t[30]; cout\"Enter string: \"; cins; cini; cint; cout

Solution

9):

char d[10]=\"hello\";//it is correct format
   char d[10]={\'h\',\'e\',\'f\'};//it is correct format
   char d[10]={\'h\',\'e\',\'f\',\'\\0\'}; it is correct format
   char d[7]=\"hello\"; it is correct format
   char d[]=\"hello\"; it is correct format
   char d[5]=\"hello\"; here string of array of chars is too long so it does not work properly

C++ PROGRAMMING. PLEASE HELP Which of the following properly define(s) the C-string containing \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site