End of Code Loop Question

This is a discussion on End of Code Loop Question within the C++ Programming forums, part of the General Programming Boards category; I only took 1 C++ class and am trying to remember how to write code to reloop my code. I ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    1

    End of Code Loop Question

    I only took 1 C++ class and am trying to remember how to write code to reloop my code. I wrote a program that asks the user to answer 5 questions, and it tells them which weather model to use based on the answers they submit. But I don't remember how to make code so that I can ask at the end if they want to test another time. Basically I have an output statement asking "Would you like to test another model (Y=Yes, N=No)" but I don't know the code to actually go through the code again. Thanks for the help

  2. #2
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    implement the whole code into a while loop

    Code:
    bool condition=true;
    
    while(condition){
        .....main program goes here
    
        .....question to continue here
    
       if(answer == 'Y'){
           condition = true;
       }else {condition =  false;}
    }
    axon
    Last edited by axon; 04-12-2003 at 01:43 PM.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please don't laugh...SIMPLE loop question!
    By the_lumin8or in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2006, 01:08 PM
  2. loop and compiling inside a code
    By MtJ in forum C Programming
    Replies: 3
    Last Post: 03-05-2006, 12:50 PM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. Next Question...
    By Azmeos in forum C++ Programming
    Replies: 3
    Last Post: 06-06-2003, 03:40 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21