Hi!
I'm very new to VC++ and need to get the square root of a number.
In VB i would use Sqrt(n)... but how in VC++?
I am making an MFC application.
Printable View
Hi!
I'm very new to VC++ and need to get the square root of a number.
In VB i would use Sqrt(n)... but how in VC++?
I am making an MFC application.
Are you new to C++ or Windows programming with C++ I would SERIOUSLY suggest if the former, that you learn the language before trying to use MFC. Actually, scrap MFC altogether and use the API :) But in answer to your question...http://www.cplusplus.com/ref/cmath/sqrt.htmlCode:#include <iostream>
#include <cmath>
using namespace std;
int main() {
float fNum = 5.4f;
cout << sqrt(fNum) << endl;
return 0;
}
I read a book about C++ (Jesse Liberty - Teach yourself C++ in 21 Days). Ok, I read until day 6 ;) :cool: :D
On its CD was an online version of "Teach yourself Visual C++ in 21 days", and I have started with this today (I'm on day 3).
I don't have problems with the C++ syntax, I can already program in PHP, HTML, VB and Delphi.
I only wanted to write a short pi-algorithmus with Visual C++, and needed the square root function. I forgot this line: #include <cmath>
Now it works, thanks for your help!
Just don't trip up on pointers and inheritance which is something that MFC uses in spades and can really mess you up.