LetsSingIt the internet lyrics database
en
0

Square root in C++

Follow 0
Share
Add topic
Search
AnTiHurLeyPUnk1
0
I'm having trouble creating a square root program in c++. I don't want to use a .00001 * 2 = root else .000002 * 2 = root. I don't want to use the to the power key or square root key. The standard formula is x to the power of .5 =root.

...I'm not sure how else to explain this.
1 to 25 of 66 comments
page 1 of 3
ViSioN
0
ViSioN | 18:07
pfft.. you're confusing me.. why not just use the root command? or is that only VB?
AnTiHurLeyPUnk1
0
wait a second...

Okay, I decided to ask a friend, and he said to use this:

#include
#include
#define TOOTH 253 //the square root symbol char. code

void main()
{
double lights;

lights=sqrt(256); //calculate the square root of 256
printf("Find the square root of:
");
printf("%i,var");
}
AnTiHurLeyPUnk1
0
do you think that'd work?
ViSioN
0
ViSioN | 18:10
i dont know c++ but the sqrt looks right to me.
AnTiHurLeyPUnk1
0
I should probably use something like gets(var); Instead of putting 256 in the sqrt function, like make it use a variable. That might work, right?
ViSioN
0
ViSioN | 18:12
yup.. that'll work for sure as long as everything else is right.
AnTiHurLeyPUnk1
0
siick! thanks a bunch, Brandon.
ViSioN
0
ViSioN | 18:17
np
AnTiHurLeyPUnk1
0
so, like what do you know? (HTML, JavaScript, etc)...?
ViSioN
0
ViSioN | 18:44
i know a fair bit of HTML, some basic turing, qbasic, and Visual Basic... and a little bit of Flash.. but i need to put more time into all of them but im kinda short of it. and when i do have time i usually go out with friends... but ya.. i wanna go into Computer Science after high school.
singingsweetie
0
*pretends to understand this thread* yeah i agree
ViSioN
0
ViSioN | 18:48
haha.. poor mariah.. its ok. *pats mariah*

ya, of the things id like to learn: Java/JavaScript, C++ are both up there in my list..
singingsweetie
0
could you people try talking about something just a little more boring? lol
AnTiHurLeyPUnk1
0
Yeah, I plan to major in Communication Arts. That way I learn more advanced HTML, how to use programs like Macromedia Flash and all of that neat stuff.
rawkerNoNagal
0
Oh yes. *nods emphatically* Definitely,
dah-ling...
ViSioN
0
ViSioN | 18:49
Flash is awesome dude.. its so much fun.. you can do such crazy stuff with it.
Gabe_M
0
Gabe_M | 18:49
Jordan should have his own lil category for HTMLs and all
singingsweetie
0
oh yeah!!?? well i know how to do landscape on microsoft word!! lol that's my newest accomplishment on the comp
AnTiHurLeyPUnk1
0
blah, I wanted one, but Dekar and Ray said it wasn't a good idea, so they beat me 2:1.
Gabe_M
0
Gabe_M | 18:54
do ya really think Ray'd give you your own category
AnTiHurLeyPUnk1
0
well my idea wasn't for it to be my category. I didn't even want to moderate it. I don't know, it's over... it was just another idea I had...
singingsweetie
0
Family Fun Night...it was just a great idea I had
singingsweetie
0
or is it Family Game Night....i don't remember
Dekar
0
Dekar | 19:58
Yeah, the sqrt() function is the way to go for square roots. I guess that's what it's there for. lol

And just a couple of comments about the code that your friend told you to use..


1) If this is supposed to be for C++, then why is there the old C-style printf() function?

2) Why are there so many unused variables in there? And there's a syntax error in the printf() function. It's supposed to be printf("%i", variable_name); //%i is for unsigned numbers, I think.

3) If you want to use the stardard way of sqaure-rooting, as you said, then use the exponential function like this..

root = pow(x, 0.5); //I'm not totally sure if you can put floating-point numbers into the pow() function as an exponent, but try it anyways

4) Nevermind, I only had 3 comments.

5) Why is there a 5 here? I didn't type this!

2x3) Hey! Just write '6', damn it!
AnTiHurLeyPUnk1
0
Holy hell! I wasn't expecting that from you!!!
guest
guest
POP OUT SAVE saving ...
Read more: