Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
C++ Tutorial
C++ Language Tutorial - Object Oriented Programing - OOPs History of C++
C++ Language Tutorial - Object Oriented Programing - OOPs Structure of C++
C++ Language Tutorial - Object Oriented Programing - OOPs C++ Datatypes
C++ Language Tutorial - Object Oriented Programing - OOPs Variables
C++ Language Tutorial - Object Oriented Programing - OOPs Constants
C++ Language Tutorial - Object Oriented Programing - OOPs Operators
C++ Language Tutorial - Object Oriented Programing - OOPs Control Structures
C++ Language Tutorial - Object Oriented Programing - OOPs Arrays
C++ Language Tutorial - Object Oriented Programing - OOPs Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Class
C++ Language Tutorial - Object Oriented Programing - OOPs Predefined Functions
C++ Language Tutorial - Object Oriented Programing - OOPs I/O Functions
C++ Language Tutorial - Object Oriented Programing - OOPs String, Character Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Mathematical Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Time Date Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Dynamic Allocation
C++ Language Tutorial - Object Oriented Programing - OOPs Utility Functions
C++ Language Tutorial - Object Oriented Programing - OOPs OOP's Concept
C++ Language Tutorial - Object Oriented Programing - OOPs Special Topics
C++ Language Tutorial - Object Oriented Programing - OOPs Type casting
C++ Language Tutorial - Object Oriented Programing - OOPs Feedback
C++ Language Tutorial - Object Oriented Programing - OOPs Ask Your Doubts
 




floor() - Mathematical Function


Tutorials Cpp

Topic

How is Mathematical Function "floor()" used in C++?
How to find the round down value of a number?



Explanation

floor() is a Mathematical Function that returns the largest integer that can be represented as a floating point value which is not greater then the given number "num". In other words , it returns the Round Down value of a given number.

Syntax:
    float floor( float num);
    double floor( double num);
    long double floor( long double num);

Example:

   #include <stdio.h>
   #include <math.h>
   int main ()
    {
       printf ("floor of 3.2 is %.1lf\n", floor (3.2) );
       printf ("floor of 3.8 is %.1lf\n", floor (3.8) );
       printf ("floor of -4.3 is %.1lf\n", floor (-4.3) );
       printf ("floor of -7.7 is %.1lf\n", floor (-7.7) );
       return 0;
    }

Result:
   floor of 3.2 is 3.0
   floor of 3.8 is 3.0
   floor of -4.3 is -5.0
   floor of -7.7 is -8.0

In the above example floor() function is used to return the round down value of the number specified.










Note
C++ is one of the most used programming languages in the world. Also known as "C with Classes". Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.

Other Links

web hosting