C++ New Lines

New Lines

To insert a new line in your output, you can use the \n character:

Example

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World! \n";
  cout << "I am learning C++";
  return 0;
}

You can also use another << operator and place the \n character after the text, like this : Continue reading C++ New Lines

C New Lines

New Lines

To insert a new line, you can use the \n character:

Example

#include <stdio.h>

int main() {
  printf("Hello World!\n");
  printf("I am learning C.");
  return 0;
}

You can also output multiple lines with a single printf() function. However, this could make the code harder to read: Continue reading C New Lines