Gender: Male Location: Chaos.
There can only be CHAOS!
How to do Square Roots in C++ - WITHOUT "SQRT" Command
K, so this is what we have so far (CompSci class)
The first two parts seem to work fine, though the third part seems to display the integer4 from the first part of the program. I know I'm missing something, if anyone can help out that has any experience, I (and my group) would be most appreciative.
**We can't use the SQRT function, as we haven't 'learned' this yet.**
Re: How to do Square Roots in C++ - WITHOUT "SQRT" Command
LoL! I think you have the wrong forums. Secondly, what is your program supposed to do? If its just body fat vs mass calculations, maybe you don't even need sqrt.
Its funny how a computer programmer can't even use google.
There's you're sqrt without sqrt, my friend. It should only require slight modification. I highly recommend you put it into its own class. Have fun.
Gender: Male Location: Chaos.
There can only be CHAOS!
A) This is the Computer/Video Games discussion, therefore this is the correct forum.
B) I've used google and all I've found for the square root is stuff that we haven't learned, thus is rendered useless, since we're not allowed to use it, much like the rest of what you've posted. I'm talking simple simple C++. The program's split into three parts. Part 1 calculates the average grade. Part 2 calculates the body mass index. Part 3 is supposed to act as the Pythagorean Theorem.
C) KMC doesn't have any code tags that I'm aware of.
Mainly, this is what I have an issue with:
since integer3=(integer4*integer4);//finds hypotenuse doesn't seem to work.
code:
cout <<"The hypotenuse of the right triangle is "<<integer3<<endl;
instead of
code:
cout <<"The hypotenuse of the right triangle is "<<integer4<<endl;
If integer3 is storing the return c^2 is'nt that the value you want printed?
To validate my previous about you having the wrong forum.
Video games make up a majority of discussion here. The odds of you finding a helpful programmer in a video game forum on a site thats dedicated to movies is'nt very high. In fact this is probably the second and probably last topic ever about C++ for some years to come. Just look at the context.
The forum description says it's for discussion of all types of video games and computers. Computer discussion used to be very common in here, it isn't so much anymore but that doesn't mean a thing. This is indeed the right forum.
Not really. Ofcourse its description says 'and Computer discussion' but that doesn't change the fact that this forum is a sore-thumb, an eye sore. The rules technically allow it, but it really doesn't belong here. Its out of place. This is just some guy trying to impress us or strain our eyes looking at this block. Bah, I say let his own damn homework. Who comes to this forum looking for C++ code, poorly written code at that.
First of all,
what better way to confuse yourself than name a variable 'integer' thats actually a float?
What is this stray, half done variable, I see? Inte?!
Are you hoping your compiler has spell check?
@ you.
What is with using the same variable for two completely different functions? Speaking of functions, have you ever heard of them?
code:
cout<<"Enter fourth grade: \n";//prompt for fourth grade
cin>>integer4
and now, all of a sudden
code:
integer3=(integer4*integer4);//finds hypotenuse
cout <<"The hypotenuse of the right triangle is "
all of this in the same block of code?
wtf?
You want us to suffer don't you , Jkozzy? Is that why you posted this? On behalf of C++, I feel embarrassed. And I thought I was terrible.
Not to slay your hopes or anything, but there's enough C++ programmers out there that can write better programs for you and you don't have to get in nitty, gritty of things.
My best advice to you is to quit programming and start cheating. Which you are already doing, to a degree.
Gender: Male Location: Chaos.
There can only be CHAOS!
Whoa. I asked for a simple answer, not for a flame
This was originally the Computer Discussion Forum, until Video Games were tacked on. I don't need spellcheck, as you can see the formatting split the word up. I've been in the course for maybe, say, four days?
integer6=integer1+integer2+integer3+integer4+inte
ger5;//assignment for sum of all grades
Hey, look, it continued on the next line because of pasted formatting. I don't need spellcheck, you need glasses.
The same variable can easily be used, as long as it is restated. As you say you haven't had a drop of C++, you're hardly one to criticize.
The variable 'integer' was pasted over from a previous program, and I didn't bother changing it, sorry if it confused you, but I'm fine with it.
I'm under the circumstances of this being a school assignment and I'm merely being told to do it in one huge program, not my choice.
I would sure hope there were better C++ programmers, because with not even a week's experience, the world wouldn't be very far at all, would it?
Asking advice isn't cheating. We're free to copy each other's programs; much simpler and productive. You obviously haven't taken a coding course, so I'm not sure why you bothered responding in the first place.
My best advice to you would be to understand the parameters of the situation before posting, or just don't post. You're wasting your and my time.
You still have no answer and you're posting your question in the least helpful place on the web. Don't tell me I need glasses just because I can't read your techno garble.
You're the one wasting your time. You'll find no answers here. And noone wants to waste their time doing your homework for you.
Gender: Male Location: Chaos.
There can only be CHAOS!
Yeah, you do need glasses. If you're gonna say you read the techno garble, well, then read the damn thing, and don't leave half of it out in a quote, criticizing that it's incomplelte when it clearly wasn't. Seriously, why do you keep coming back? Do you really not have a life that you need to think up dribble to put people down on the internet? Seems those glasses really would help you; I asked you that if you can't help, to not post. This is a forum, not an all-out flame war on a subject you clearly don't understand.
You think this is flame war? I was just commenting on your block. Its not like, I did a full-out assault on you. Just relax, play some video-games or something. You don't really have to quit just because I told you.
If it makes you feel any better, I think you're the best programmer in the whole of KMC.
Gender: Male Location: Chaos.
There can only be CHAOS!
No, but you certainly seem to want to make it that. You're not contributing an answer, so I'd appreciate it if you would let other people post. And learn to spell.
If any thing I'm helping this silly thread, because otherwise it would probably be pushed to the second page(or nearly) by now. Don't you know when someone is helping you? I bet you have'nt even tried out any of my suggestions yet.
Gender: Male Location: Chaos.
There can only be CHAOS!
Yeah, I know how to spell, though. You can keep that advice, you'll need it. And, wow, uh, gee, thanks for all that... help. Yeah, @ you. That definately did quite a doozy on the program. You know, maybe I'm wrong. You've been such a valuable asset in your vast knowledge of the C++ language. The sarcasm really gave it a nice touch, too. Yeah. Actually, I do know when someone's helping me. And, uh, you don't really fit that description.
Hey, why don't you stop being an ass? You've done nothing but troll around in this thread and your so-called 'help' that you keep referring to has yet to be located. He asked a question and if you don't know the answer, instead of being a smartass, why don't you just keep your mouth shut?
Oi.
Anyway, I have no idea man. I tried a mess of different ways to work around it and couldn't find a way to do it.
We both don't have the answer and theres nothing but love in our posts here so far.
But I actually did post one helpful suggestion.
code:
cout <<"The hypotenuse of the right triangle is "<<integer4<<endl;
seems more like it should be
code:
cout <<"The hypotenuse of the right triangle is "<<integer3<<endl;
I just look at it and thought that since their are no actual calculations are being stored in integer4 that maybe, just maybe integer3 was intended instead. Maybe. But if I'm wrong, feel free to shoot me down.
jerlark386, if you don' t have any interest in the topic, nor have anything worthwhile to contribute to the discussion, don' t post for the sake of it and simply don' t participate.
__________________
I am not driven by people’ s praise and I am not slowed down by people’ s criticism.
You only live once. But if you live it right, once is enough. Wrong. We only die once, we live every day!
Make poverty history.
Last edited by Storm on Oct 28th, 2005 at 10:10 AM
code:
cout <<"Enter the first side of the right triangle\n";//assign first side
cin >> integer1;//redefine integer1
cout <<"Enter the second side\n";//assign second side
cin >> integer2;//redefine integer2
integer3=(integer1*integer1)+(integer2*integer2);
//finds hypotenuse squared
integer3=(integer4*integer4);//finds hypotenuse
cout <<"The hypotenuse of the right triangle is "<<integer4<<endl;
return(0);//indicate that the program has ended successfully
}
Its a really minor error. You can fix it with this.
code:
cout <<"Enter the first side of the right triangle\n";//assign first side
cin >> integer1;//redefine integer1
cout <<"Enter the second side\n";//assign second side
cin >> integer2;//redefine integer2
integer3=(integer1*integer1)+(integer2*integer2);
//finds hypotenuse squared
//integer3=(integer4*integer4);//finds hypotenuse//get rid of this line
cout <<"The hypotenuse of the right triangle is the square root of"<<integer3<<endl;
return(0);//indicate that the program has ended successfully
}
So you can't use the sqrt or the breakdown version in my other post. Then don't. Without those, you're pretty much out of luck anyway. Besides your teach would'nt liked all those gotos anyway. If you give an answer that sounds good, then it'll probably be better than nothing. Your teacher will laugh, but your answer will be 'valid'.