-
I need again function
hey if any1 wuld mind could some1 write an again statement for me ill ....... im creating a basic program that will add subtract ect and i need to know hw to do the again function so if u lets say do the dividing after it would ask u if u wanted to do it again and it would go back to the push d to divid ect
-------------------------------------------------------------------------------
here is my program so far
__________________________________________________ __
[html]
[tag]
#include <iostream.h>
int main ()
{
char c;
int x,y,z;
cout << " -------" << endl;
cout << " Welcome" << endl;
cout << " -------" << endl;
cout << "Push q if u would like to square, d to divide, s to subtract, a to add, and m to multiply"<< endl;
cin >> c;
if((c == 'q')||(c == 'Q'))
{
cout << "\nEnter a number: ";
cin >> x;
y = x * x;
cout << x << " squared is "<< y << endl;
}
if ((c == 'd')||(c == 'D'))
{
cout << "\nEnter a dividend: "
cin >>
return 0;
}
[/tag]
[/html]
-
Just put the things you want to repeat in a while loop.
Code:
while( !bDone ) // Equivalent to bDone == false
{
// Statements....
// ....
}
Add something in your menu to check to see if the person wants to stop. Then set your boolean variable bDone to true and the program will stop looping. I think that answers your question.