understanding problem

Hello, I don't understand one thing in the following program,and I decided to ask you.
#include <iostream>
using namespace std;

#define PI 3.14159
#define NEWLINE '\n'

int main ()
{
double r=5.0;
double circle;

circle = 2 * PI * r;
cout << circle;
cout << NEWLINE;

return 0;
}

I didn't understand from the tutorial what exactly is newline '\n' and what exactly does.
newline makes a new line (like its name) in your program, for example:

this is a line
this is a line made in another line by making a new line in program...
Last edited on
closed account (zb0S216C)
Think of the this way. Below, I've replicated an output buffer. Notice all of the characters within the buffer. Also, notice the \n (newline escape sequence).

'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', '\n', 'l', 'i', 'n', 'e', '.'

If I print this, the result should be like this:

This is a
line.

Notice how the newline escape sequence wasn't printed.

Wazzak
Topic archived. No new replies allowed.