
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are C++ Floating Point Constants
Floating-point constants specify values that must have a fractional part.
Floating-point constants have a "mantissa," which specifies the value of the number, an "exponent," which specifies the magnitude of the number, and an optional suffix that specifies the constant's type(double or float).
The mantissa is specified as a sequence of digits followed by a period, followed by an optional sequence of digits representing the fractional part of the number. For example −
24.25 12.00
These values can also contain exponents. For example,
24.25e3 which is equivalent to 24250
In C++ you can use the following code to create a floating point constant −
Example
#include<iostream> using namespace std; int main() { const float PI = 3.141; // 3.141 is floating point constant while PI is a constant float. cout << PI; return 0; }
Output
This will give the output −
3.141
Advertisements