Data Types Question

#include <iostream>
using namespace std;

#define PI 3.14159265358979
#define NEWLINE '\n' //no idea what newline does

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

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

return 0;
}


When I run this code, all i get is 31.4159. My question is why don't I get 31.4159265358979. Also, what is newline? I'm not sure what it does.
NEWLINE adds a new line to the output. If it were a text file, NEWLINE would be the equivalent of pressing the ENTER key. But don't use NEWLINE as defined there. Use std::endl. Better.

You also don't get the entire precision because the output's precision is not set. See http://www.cplusplus.com/reference/iostream/manipulators/setprecision/ .
Topic archived. No new replies allowed.