Current location - Loan Platform Complete Network - Big data management - How to express VC++ natural constant e
How to express VC++ natural constant e
It can't be expressed accurately at present.

The data type of natural constant e is not defined in C++.

But they can be expressed by mathematical functions, but they cannot be expressed accurately, because e is an infinite decimal and the computer represents a certain value. If you use a mathematical expression to find this e on the computer, you might as well define it as a constant directly, with similar accuracy.

An algorithm is needed to calculate

# Contains? & ltiostream & gt

Use? Namespace? std?

int? Master ()

{?

Double? e? =? 1.0;

int? n=? 0; ?

Double? u? =? 1.0;

do

{?

n? ++;

u? =? u/n;

e? =? e+u;

} while(u & gt; = 1.0E-6);

cout? & lt& lt? “e? =? "? & lt& lt? e? & lt& lt?" ? (? n? =? "? & lt& lt? n? & lt& lt?" ? )"? & lt& lt? endl

Return? 0;

}