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?

Recommended Answers

All 5 Replies

>>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)

read your text book. while is just one of several types of loops. See this tutorial

wish i was good at this! humph!!

wish i was good at this! humph!!

You will be. Hooray!!!

Just takes practice...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.