Exercise 1_2 multiple console outputs. I would like to reduce the number of console output statements Please could we examine the below code for anyway to put all console output in one statements?

 #include &lt;iostream&gt;
 using namespace std;

 int main( )
 {  //print("") in Python
   cout&lt;&lt;"Hello " "everybody!"&lt;&lt;endl;
   cout&lt;&lt;"My name is AK."&lt;&lt;endl;
   cout&lt;&lt;"Goodbye."&lt;&lt;endl;
   cout&lt;&lt;""&lt;&lt;endl;

   //Poem
   cout&lt;&lt;"Twinkle, twinkle, little bat!"&lt;&lt;endl;
   cout&lt;&lt;"How I wonder what you're at?"&lt;&lt;endl;
   cout&lt;&lt;"Up above the world you fly,"&lt;&lt;endl;
   cout&lt;&lt;"Like a tea-tray in the sky."&lt;&lt;endl;
   return 0;
}
Scope

This is really just limited to style and code formatting. 

Two (almost) substantive points


You should get in the habbit of not:


using namespace std;


It can get you into name-clash issues later, as you progress. 


You should be aware that std::endl flushes the stream buffer. This is often unnecessary, unwanted and can be slow if used in a tight loop. You should use '\n' for most situations. If you are worried about
platform specific line-ending, don't be. '\n' adapts, just like
std::endl.


Code formatting


Install clang-format or similar to help you with formatting. 


All I did was to integrate your endl into the strings and hit "auto-clang-format" and I got this:

#include &lt;iostream&gt;

int main() {
  std::cout &lt;&lt; "Hello everybody!\n"
            &lt;&lt; "My name is AK.\n"
            &lt;&lt; "Goodbye.\n"
            &lt;&lt; "\n"

            // Poem
            &lt;&lt; "Twinkle, twinkle, little bat!\n"
            &lt;&lt; "How I wonder what you're at?\n"
            &lt;&lt; "Up above the world you fly,\n"
            &lt;&lt; "Like a tea-tray in the sky.\n";
  return 0;
}



Which is "good enough for me". Clang format is very tunable, and I have it configured to something which works for me, and my team, in 99% of cases. So we don't spend time fighting the formatting of the code. 

The above style with "one streaming operator" &lt;&lt; at the beginning of each line is what we use most of the time. It makes sense when you have literals interspersed with variables and/or function calls. 

For this very specific (and rather atypical?) case, you could, as someone else pointed out, also just stream it all as one continuous literal. C++ allows you stop/start string literals like this:

#include &lt;iostream&gt;

int main() {
  std::cout &lt;&lt; "Hello everybody!\n"
               "My name is AK.\n"
               "Goodbye.\n"
               "\n"

               // Poem
               "Twinkle, twinkle, little bat!\n"
               "How I wonder what you're at?\n"
               "Up above the world you fly,\n"
               "Like a tea-tray in the sky.\n";
  return 0;
}



Hope that helps.