floor() in C++

Overview
The floor in C++ is an inbuilt function that returns an integer value that is less than or equal to the argument. For example, the function floor(3.78) will return the integer value of 3 as an output. The floor in C++ is defined in the <Cmath> header file.
What is floor() in C++
In C++, the floor function returns the largest integer, which is less than or equal to the given argument. The floor in C++ is defined in the cmath header file in C++.
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Example
Output
Explanation
The code discussed above passes a floating value of to the floor function as an argument. The largest integer which is less than or equal to is . Thus the floor function returns an integer value of as the output.
Syntax of the floor in C++
The syntax of the floor in C++ is as follows:
We need to pass the argument inside the function of which we want the floor value as an output. The argument can be a real number of any data type.
Parameters of the floor in C++
The floor in C++, defined in the cmath header file, takes a floating-point number whose floor value is to be computed. The parameters can be of the type:
- double
- long double
- float
Note: When an integer value is passed inside the floor function as an argument, it is type cast into a double data type.
Return Value of floor in C++
The floor in C++ returns an integer value that is less than or equal to the argument passed in the floor function.
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
floor for Integer Values in C++
When an integer value is passed to the floor in C++ as an argument, the return value is equal to the argument itself.
Example
Output
floor for Double and Float Values in C++
When a floating-point number is passed as an argument, the floor in C++ returns the largest integer that is less than or equal to the argument.
Turn Learning into Career Growth
Example
Output
Special Cases for floor in C++
Below are some of the special cases of the in C++.
Output
Conclusion
- The is an inbuilt function in C++ that returns an integer value that is less than or equal to the argument.
- Similar to the floor in C++, the function in C++ returns an integer value greater than or equal to the argument.




