January 18th, 2002, 02:52 AM
C++ Homework Help (while loop)?
int number = 0;
int number2 = 0;
int response = 0;
while (response = 5)
void main ()
cout<<"Enter the first number: ";
cout<<"Enter the second number: ";
cout<<"Menu Items\n 1)add\n 2)subutract\n 3)multiply\n 4)divide\n";
if (response != 1-4)
cout<<"That is not a valid number"<<endl;
cout<<number + number2<<endl;
cout<<number - number2<<endl;
cout<<number * number2<<endl;
cout<<number / number2<<endl;
Basically I don't want the program to exit once I get an anser.
So I put in a while loop to equal 5 so every equation gets worked once, but I know it's not right and my reference book doesn't give much insight to what I'm supposed to do. Could someone help me by telling me where to put this while loop in?
It's C++ and I'm using the Micorosoft Visual, this is a ms-dos .exe so at the end of the program I get that "Press any key" thing.