#include <math>
gives error on linux compiler g++
can anybody guide how functions like sqrt() are to be used
Printable View
#include <math>
gives error on linux compiler g++
can anybody guide how functions like sqrt() are to be used
try #include <cmath>
c libraries start with an extra c in c++(ie cmath, cstdio, ctime)
The correct header from C is <math.h>. This is deprecated in C++ so <cmath> should be used instead (in which case math functions like sqrt() will live in namespace std).
The other usual requirement (assuming you have #include'd required headers) is to add -lm to the command line when linking, so as to link functions from the math library into the executable.