Is there a function i can use to figure the square root of numbers? i was trying to make a program for solving pythagorean theorem problems for my friend, but i can't find the square root of C haha. If its not possible let me know
btw, im a noob...
Square Roots
Started by Olympiaus, Feb 28 2009 11:37 PM
6 replies to this topic
#1
Posted 28 February 2009 - 11:37 PM
|
|
|
#2
Posted 01 March 2009 - 12:31 AM
Code;
Description;
"sqrt" returns the square root of "x". If "x" is negative, "sqrt" returns zero and sets "errno" to EDOM.
#include <math.h> y = sqrt(x);
Description;
"sqrt" returns the square root of "x". If "x" is negative, "sqrt" returns zero and sets "errno" to EDOM.
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!
#3
Posted 01 March 2009 - 04:38 AM
Wow great help Brandon. Didn't know that you knew some C++.
Olympiaus, I wanna bring your attention to this math bits page: Math Functins in C++
It lists a bunch of mathematical functions in C++. The one you are interested in is hypot(a,b).
Olympiaus, I wanna bring your attention to this math bits page: Math Functins in C++
It lists a bunch of mathematical functions in C++. The one you are interested in is hypot(a,b).
#4
Posted 01 March 2009 - 10:48 AM
#5
Posted 01 March 2009 - 11:11 AM
More generally, to find the nth root of x, use pow(x, 1.0/n).
#6
Posted 01 March 2009 - 01:05 PM
Your welcome mate, if you need any further help just ask and we shall reply as soon as possible ;)
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!
#7
Posted 30 April 2009 - 06:45 AM
Our class wrote actually wrote a program that calculated it:
while (cin)
{
if (a<=0)
cout << "******Can you please insert a positive integer!*******";
cout << endl;
break;
}
cout << endl;
do
{ //calculation to find the root
x=(x+a/x)/2;
cout << "The Square root of" << " " << a << " " << "is" << " " << x <<endl;
}
//parameter for when to stop calculation
while (x-a/x>=0.000001);
Edited by WingedPanther, 30 April 2009 - 07:07 AM.
add code tags (the # button)


Sign In
Create Account


Back to top









