Thread: Again function

  1. #1
    Registered User Prodigy's Avatar
    Join Date
    May 2002
    Posts
    25

    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]
    Last edited by Prodigy; 05-04-2002 at 08:59 PM.
    And the cows moo...
    AIM:ProdigyCpp
    E-Mail:[email protected]
    If you like my avatar plz dont copy it go to:
    http://www.dragid.com/

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM