+ 6
How can i calculate the log, ln, sin, cos, square root....... In C++
a bit useful home-made calculator
8 Answers
+ 11
@Ahmad, I dunno what compiler you are using but that's not a Standard library for compilers like GNU/MinGW and the like.
+ 10
<cmath> or <math.h> both can do all of those things. Or hey, you could create them yourself if you know enough about mathematics đ
+ 10
first of all, you should include this library <bits/stdc++.h> for all function not for math function only and for string and so...
you can forgot all library that you saved
the sin function:
sin(x);//in radian
sin(x*(3.14/180));//in degrees
the cos function:
cos(x);//in radian
cos(x*(3.14/180));//in degrees
the tan function:
sin(x)/cos(x);//in radian
sin(x*(3.14/180))/cos(x*(3.14/180));//in degrees
and so...
the square function:
sqrt(x);
the abs function:
abs(x);//abs(7-9);2 not -2
GOOD LUCK...
+ 9
@Sorakatadzuma,I use code blocks editor which use GNU compiler and i try it in code playground and i try it on my mobile "C++ Compiler IDE" and this library work
+ 8
@seamiki I think @Amr didn't include them since they are supported by usual syntax
+ 7
Try to Google more on simple questions like that.
I think <cmath> should do some of those
+ 7
you need to declare bibliotec of <math.h > and the code of square is sqrt()
+ 4
you forgot addition, subtraction, division and multiplication...
Edit: don't know which one is funnier:)