When do we include cmath and when do we include math.h? Do they mean the same thing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

When do we include cmath and when do we include math.h? Do they mean the same thing?

was trying to learn how to use pow function...

24th Nov 2017, 5:11 AM
Just A Learner
Just A Learner - avatar
4 Answers
+ 2
thanks๐Ÿ‘
24th Nov 2017, 5:34 AM
Just A Learner
Just A Learner - avatar
+ 1
cmath is C++ way of including those functions like power ,squareroot,floor ect. while math.h is the older way from the C language. so basically they are the same
24th Nov 2017, 5:28 AM
Mind To Machine ๐Ÿ’ป๐Ÿ•†
Mind To Machine ๐Ÿ’ป๐Ÿ•† - avatar
+ 1
so if math.h is an older version why do we still use it in c++..? does it have something to do with lesser compilation time or something... you know.. cuz it's got lesser functions that we could include in our program so it probably would take less time for the computer to go through all the functions and picking the function that we need?๐Ÿค”..(just asking)
24th Nov 2017, 5:55 AM
Just A Learner
Just A Learner - avatar
+ 1
cmath and math.h should give you access to the same functions. math.h works in cยฑ+ also so that c++ compilers will more compatible with c code.
24th Nov 2017, 9:46 AM
Jared Bird
Jared Bird - avatar