Performing square root calculations in c++?

  • Thread starter Thread starter Ant
  • Start date Start date
Status
Not open for further replies.
There is a header file you can include called math.h
Then you can use the function

sqrt(the number you want to squareroot);
 
Don't think so; C++ has this fixation with using symbols for as many things as possible ... I believe ^ is used to do binary XOR.
 
C++ has the pow(number, tothepowerof) function, I think. It's in the math.h library.
 
Aaron : I was doing that for a while wondering why it was spewing out some hideous result.(Too much VB on the brain - not a good thing :smile: )
 
i dont completely understand the isdigit command of ctype.h..... I input 5 and get 4..... why? shouldn't i get 1?
 
On 2001-11-27 19:48, Darkness wrote:
i dont completely understand the isdigit command of ctype.h..... I input 5 and get 4..... why? shouldn't i get 1?
How exactly did you use it?
 
i was messing with it in my c++ class today......

something like this:

cin >> i;
x = isdigit(i);
if (x == 1)
{
       cout << "Character is a Digit";
}
else
{
       cout << "Character is not a Digit";
}
 
As the help says, isdigit returns nonzero if it is a number, else returns 0.

In c++ false = 0. true = anthing else.

fix that line to: if ( x )
or make it:
if (x == 0)
   cout << "Character is not a Digit";
else
   cout << "Character is a Digit";
 
yup. i fixed it earlier today. thats the EXACT words of my textbook.
 
Status
Not open for further replies.
Back
Top