How to write mathematical functions in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to write mathematical functions in c++?

6th Apr 2017, 3:04 PM
Anandita Dey
2 Answers
+ 18
Which kind of functions? If you mean power, square root, absolute value, trigonometric functions etc., then there are library functions to calculate these. See this reference: http://www.cplusplus.com/reference/cmath/
6th Apr 2017, 3:21 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 2
you can use function of math.h to carry out operations like square root, sin, cos, tan etc. e.g. to calculate square root use sqrt(num) or to raise a number to power use pow(num, exponent);
6th Apr 2017, 3:29 PM
Karan Vaity
Karan Vaity - avatar