Would anybody know a way to repeat a program, for example the user has reached the end and a prompt is shown on screen Would you like to try again? Press y, n. I have managed to do this using goto command but this as ive read is a no go zone unless really needed. I have also found bool to be of some use.

Also i have 3 if statements working to filter through a user value that has to be between 3 and 31 and odd.

    cout << "Please enter an odd value between 3 and 31: " << endl;
    cin >> rate;
    myWaveForm.getSampleValue( rate );

    cout << endl;

    //upto here we have a value that the user has entered

    if ( rate % 2 != 1 ){ 
      else rate = rate; }

    if ( rate <3 ){ 
        if ( rate > 31 );}
        else rate = rate; 

Is there a way of simplifying this?

Edited by mike_2000_17: Fixed formatting

9 Years
Discussion Span
Last Post by WaltP

>>Would anybody know a way to repeat a program
use a loop

while( not done )
    // display menu
    // get input
    // if 'Q' entered then exit the loop
    // do something

Not sure what you are trying to do that that code you posted. But rate = rate; doesn't do anything, so you might as well just replace it with a simple semicolon.


Is that 'while' you put there a loop? i initally thought of a counter (being a beginer to this i only know counters as loops)

This article has been dead for over six months. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.