Printing Output in Multiple Lines in C++ Last Updated : 23 Jul, 2022 Comments Improve Suggest changes Like Article Like Report This article focuses on discussing how to use cout for multi-line printing. This can be easily done using any of these two methods: Using endl.Using \n. Let's discuss each of these methods in detail. Using endl The endl statement can be used to print the multi-line string in a single cout statement. Below is the C++ program to show the same: C++ // C++ program to show endl statement // can be used to print the multi-line // string in a single cout statement #include <iostream> using namespace std; // Driver code int main() { cout <<" GeeksforGeeks is best" " platform to learn " << endl << " It is used by" " students to gain knowledge" << endl << " It is really helpful"; return 0; } Output GeeksforGeeks is best platform to learn It is used by students to gain knowledge It is really helpful Time complexity: O(1)Auxiliary Space: O(1) Using '\n' '\n' can be used instead of endl to print multi-line strings. Below is the C++ program to implement the above approach: C++ // C++ program to show '\n' can be // used instead of endl to print // multi-line strings #include <iostream> using namespace std; // Driver code int main() { cout << " GeeksforGeeks is best" " platform to learn \n It" " is used by students to" " gain knowledge \n It is" " really helpful"; return 0; } //Main key points here are : //You can write as many statements as you want in a single line, //but I recommend you to write one statement per line to keep the code neat and clean. //Anything which is written between double quotation " " is a string literal. Output GeeksforGeeks is best platform to learn It is used by students to gain knowledge It is really helpful Time complexity: O(1)Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Printing Output in Multiple Lines in C++ R raunakkr819 Follow Improve Article Tags : C++ Practice Tags : CPP Similar Reads How to write long strings in Multi-lines C/C++? Image a situation where we want to use or print a long long string in C or C++, how to do this? In C/C++, we can break a string at any point in the middle using two double quotes in the middle. Below is a simple example to demonstrate the same. C #include<stdio.h> int main() { // We can put tw 2 min read Line Splicing in C/C++ While writing a program, sometimes we give comment about the working of the code in the comment section with the help of single/double comment line. But we had never thought that if at the end of this comment line if we use \(backslash) character then what will happen?The answer of the above questio 2 min read Basic Input / Output in C++ In C++, input and output are performed in the form of a sequence of bytes or more commonly known as streams.Input Stream: If the direction of flow of bytes is from the device (for example, Keyboard) to the main memory then this process is called input.Output Stream: If the direction of flow of bytes 5 min read Output of C++ programs | Set 34 (File Handling) What task does the following program perform? CPP #include<iostream> #include<fstream> using namespace std; int main() { ofstream ofile; ofile.open ("text.txt"); ofile << "geeksforgeeks" << endl; cout << "Data written to file" << endl 3 min read getline (string) in C++ The C++ getline() is a standard library function that is used to read a string or a line from an input stream. It extracts the characters from the input stream and appends it to the given string object until the delimiting character is encountered.Example:C++#include <bits/stdc++.h> using name 3 min read Like