How to Insert a New Line in C++

Insert a New Line in C++:

(1) \nis used for inserting a new line or print output in the next line

(2) Sample C++ language code and its output, as shown:

Sample C++ code for inserting new line
#include <iostream>
using namespace std;
 
int main() {
  cout << “My first C++ Language Line!\n”;
  cout << “My second C++ Language Line!\n”;
  return 0;
}

(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.

Build C++ code for inserting new line

(4)  After building the code, press the “Run” button, as shown.

Run c++ code for insert new line

(5) After pressing the “run” button, the output screen is opened, as shown.

C++ output screen for insert new line

(6) “\n”: Enter one “\n” means to insert only one line, if you enter two “\n\n” then the system inserts two lines and vice versa.


SWITCH Statement in C Language
FOR Loop in C Language
WHILE Loop in C Language
DO WHILE Loop in C Language
Use of LOWER Function in SQL
REVERSE (Transact-SQL)– Microsoft Docs

Leave a Reply