What does the constant E do in the c language
The documentation for floating-point constants is here.
The form 1e2
or 1E2
means 1
times ten to the power of 2
, and you’re perfectly correct that 2E-1
means 2
times ten to the power of -1
, or 0.2
.
It’s based on the scientific E notation linked by Eugene.
When I run the code it prints a weird number
That’s just because you used the wrong format specifier. These are documented here, and you can see you should use one of eEfFgG
for doubles.
solved What does the constant E do in the c language [duplicate]