Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ Math

// Include the cmath library
#include <cmath>

cout << sqrt(64);
cout << round(2.6);
cout << log(2);
Comment

math functions c++

#include <cmath>//this is a library that gives us access to some math functions in c++

cout << pow(2,3);//power with base and power
cout << sqrt(123);//for square root
cout << round(2.34);//round number to the nearest value
cout << ceil(4.1);//always round upword
cout << floor(4.9);//round down
cout << fmax(3,10);//return the larger number
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ vector first element 
Cpp :: passing custom function in sort cpp 
Cpp :: vector of threads thread pool c++ 
Cpp :: exception handling class c++ 
Cpp :: sort strings by length and by alphabet 
Cpp :: online ide c++ 
Cpp :: Fisher–Yates shuffle Algorithm c++ 
Cpp :: C++ Calculating the Mode of a Sorted Array 
Cpp :: how creat matrix column in c++ 
Cpp :: c++ fill two dimensional array 
Cpp :: C++ wchar_t 
Cpp :: max pooling in c++ 
Cpp :: Pseudocode of Dijkstra’s Algorithm in C++ 
Cpp :: create a vector of size n in c++ 
Cpp :: C++ if...else...else if 
Cpp :: Operators in C / C++ 
Cpp :: opengl draw house using glut c++ 
Cpp :: declare a tab c++ 
Cpp :: std::map get all keys 
Cpp :: c++ memset 
Cpp :: C++ Vector Operation Access Elements 
Cpp :: use set to get duplicates in c++ 
Cpp :: Basic Makefile C++ 
Cpp :: C++ pointer to base class 
Cpp :: c++ comment 
Cpp :: c++ stl 
Cpp :: rgb type def 
Cpp :: c++ string replace 
Cpp :: coinPiles 
Cpp :: fabs c c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =