Thread: Again function

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

    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
    __________________________________________________ __
    #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;
    Last edited by Prodigy; 05-04-2002 at 08:59 PM.
    And the cows moo...
    If you like my avatar plz dont copy it go to:

  2. #2
    Registered User
    Join Date
    Apr 2002
    Just put the things you want to repeat in a while loop.
    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