+ 6

How can i calculate the log, ln, sin, cos, square root....... In C++

a bit useful home-made calculator

11th Apr 2017, 6:44 PM
Amr Almatni
Amr Almatni - avatar
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.
14th Apr 2017, 7:55 AM
SoraKatadzuma
SoraKatadzuma - avatar
+ 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 😉
11th Apr 2017, 8:19 PM
SoraKatadzuma
SoraKatadzuma - avatar
+ 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...
14th Apr 2017, 7:49 AM
Ahmad Abomahmod
Ahmad Abomahmod - avatar
+ 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
14th Apr 2017, 10:40 AM
Ahmad Abomahmod
Ahmad Abomahmod - avatar
+ 8
@seamiki I think @Amr didn't include them since they are supported by usual syntax
11th Apr 2017, 7:10 PM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
+ 7
Try to Google more on simple questions like that. I think <cmath> should do some of those
11th Apr 2017, 7:06 PM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
+ 7
you need to declare bibliotec of <math.h > and the code of square is sqrt()
11th Apr 2017, 9:52 PM
Badr
Badr - avatar
+ 4
you forgot addition, subtraction, division and multiplication... Edit: don't know which one is funnier:)
11th Apr 2017, 7:09 PM
seamiki
seamiki - avatar