PDA

For continued disscussion on this topic : C++



scoobydude
05-13-2001, 06:04 PM
Wow, I haven't been here in a long time!
Well, I decided I wanted to make a C++ program, and I didn't feel like reading my book (go figure) so could you help me on this one?

I guess you'll kinda get the idea of what I want...
I think there might be some #include thing to use booleans.



#include <iostream.h>
#include <string>

string int1, int2, int3;
bool go;

int main()
{
cout << "Type in a number, press enter, then type in another, and press enter." << endl;
cout << "I will tell you the sum of those two numbers." << endl;
while(go == true)
{
cin >> int1;
cin >> int2;
if(int1 == "exit" || int2 == "exit")
break;
cout << int1 << " + " << int2 << " = " << int1+int2;
}
return 0;
}

Kool Dude
05-16-2001, 07:21 AM
Hmm.. my best guess...

I don't see where the variable go is given a value (like in an option to exit the loop)? :bambooz:

voicebox
05-16-2001, 07:54 PM
Hey Kool dude,

I think the loop is exited here:

if(int1 == "exit" || int2 == "exit")
break;

scoobydude
05-16-2001, 10:50 PM
hmmm... answering his question, but not mine. ;)

Orphious
05-18-2001, 04:48 AM
why not just read in the variables in one swoop
cin<<num1<<num2; so you dont have to fool with people screwin up the number then enter second number
go doesnt seem to be assigned a value either.
your testing for go == true, but where did you ever declare what go was, either true or false.

scoobydude
05-19-2001, 02:25 AM
hiya orphious! my old pal...
if i do cin >> num1 >> num2 wont they both be the same thing?

Orphious
05-19-2001, 03:29 AM
as long as they are seperated they wont. like so
they enter 87 91. cin<<num1<<num2 will set num1=87 and num2=91

scoobydude
05-19-2001, 03:41 AM
but then they could type 55 44 33 55

what would it do then?

Orphious
05-19-2001, 03:45 AM
If you expect people to not follow directions you would need some error checking

scoobydude
05-19-2001, 03:57 AM
so, hows it goin? :D

Orphious
05-19-2001, 04:02 AM
just finished up all the c++ classes for my university, so I now know, recursion, classes, linked lists, structs, and a buttload more things, Or do I?

scoobydude
05-19-2001, 04:04 AM
Can you do windows programs or just console ones?

Orphious
05-19-2001, 04:07 AM
They never teach you anything useful. I can do console ones......dont ask me what I will do with that. I'd like to learn windows programming just for kicks but all the programming classes where in the console :(

scoobydude
05-19-2001, 04:12 AM
can you write me a personalized program?

Orphious
05-19-2001, 04:13 AM
Describe "personalized program"

scoobydude
05-19-2001, 04:14 AM
i dunno
one that has my name in it ?

Orphious
05-19-2001, 04:15 AM
You mean in a console?

scoobydude
05-19-2001, 04:15 AM
hey this is almost like instant messaging!

scoobydude
05-19-2001, 04:16 AM
sure in a console

Orphious
05-19-2001, 04:17 AM
ya IM me hehe :D You know how to display you name in the console. Im not following this.
<---- confused as hell

scoobydude
05-19-2001, 04:18 AM
make me a program that says "Hello!" every 10 seconds

Orphious
05-19-2001, 04:20 AM
why? You just want one that say hello every ten seconds?

scoobydude
05-19-2001, 04:35 AM
yes!

[im testing your skill] :P

Orphious
05-19-2001, 04:39 AM
ok, ill do it tomorrow perhaps. Im workin on a flash intro at the moment

scoobydude
05-19-2001, 04:48 AM
Well if it's so easy, why cant you make it and go back to work?

Orphious
05-19-2001, 04:51 AM
besides, I am working on flash so I dont feel like it right now.